If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Form used for ADD and CHANGE?
My question relates to best methods.
The application has a "swithboard" type form that allows the user to: 1) ADD a test 2) REVIEW a test (allows for changing the data) Is it best (or is there a great technique or tip) to use one FORM for this and set it to either do an ADD or REVIEW based on the call from the "switchboard" form. THANKS, MEG |
#2
|
|||
|
|||
Form used for ADD and CHANGE?
That would be my recommendation, as it gives you only one form to maintain.
You can pass a string such as "ADD" or "REVIEW" to the form when it opens (in the DoCmd.OpenForm call), and in the Form_Open or Form_Load event take appropriate steps depending on which string was passed. Carl Rapson "MEG" wrote in message ... My question relates to best methods. The application has a "swithboard" type form that allows the user to: 1) ADD a test 2) REVIEW a test (allows for changing the data) Is it best (or is there a great technique or tip) to use one FORM for this and set it to either do an ADD or REVIEW based on the call from the "switchboard" form. THANKS, MEG |
#3
|
|||
|
|||
Form used for ADD and CHANGE?
Thank you for the response.
Since I sent this post, I met with the user. The access database is used after doing some functions in another application. This application has functionality to call the access database with a command line. Therefore, to make it easier for the user, I'm looking to incorporate the command line into the access database. I have started this process and I'm passing the following: FORM ACCOUNT ACTION FORM can be one of three (FORM1, FORM2, FORM3) ACCOUNT is the ACCOUNT number they want to add or display a record ACTION is the whether to ADD a record for the ACCOUNT or DISPLAY a record for the ACCOUNT I've successfully broken the command line into the 3 above parts. What I could use help with is the code to open the form and do the two actions. THANKS, MEG "Carl Rapson" wrote: That would be my recommendation, as it gives you only one form to maintain. You can pass a string such as "ADD" or "REVIEW" to the form when it opens (in the DoCmd.OpenForm call), and in the Form_Open or Form_Load event take appropriate steps depending on which string was passed. Carl Rapson "MEG" wrote in message ... My question relates to best methods. The application has a "swithboard" type form that allows the user to: 1) ADD a test 2) REVIEW a test (allows for changing the data) Is it best (or is there a great technique or tip) to use one FORM for this and set it to either do an ADD or REVIEW based on the call from the "switchboard" form. THANKS, MEG |
#4
|
|||
|
|||
Form used for ADD and CHANGE?
After you've parsed the command line (I assume that's what you meant by
'broken'), open the form as follows: DoCmd.OpenForm strForm,,,,,,strAccount & "+" & strAction This assumes: 1. strForm contains the name of the form to open 2. strAccount contains the Account number. The syntax above assumes the account number is a string; if it's numeric, remove the single quotes: DoCmd.OpenForm strForm,,,,,,strAccount & "+" & strAction 3. strAction contains the action to be performed Note that I'm concatenating the Account and Action strings together, separating them by a "+" just so we have something to parse them by. If there is a chance that the Account string will contain a plus sign, you can use any other character you wish to separate the two strings. In the form's Open event, parse the Account and Action strings into module-level variables (declared at the top of the module, before the first procedure): Dim strAccount As String ' if Account is numeric, declare as follows ' Dim lngAccount As Long Dim strAction As String ... Private Sub Form_Open() strAccount = Left(Me.OpenArgs, InStr(Me.OpenArgs, "+") - 1) strAction = Right(Me.OpenArgs, Len(Me.OpenArgs)-InStr(Me.OpenArgs, "+")) End Sub In the form's Load event, check the action as follows: If Me.OpenArgs = "ADD" Then ' Add a new record for the Account DoCmd.GotoRecord , , acNewRec Me![Account] = strAccount ElseIf Me.OpenArgs = "DISPLAY" Then ' Locate the record for this Account Dim rs as Recordset set rs = Me.RecordsetClone rs.FindFirst "[Account] = '" & strAccount & "'" ' if Account is numeric, use the following line instead: ' rs.FindFirst "[Account]=" & lngAccount If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark Else ' Account not found! End If rs.Close Set rs = Nothing Else ' In case there is another possibility for the Action End If Understand, these are just some ideas. Be sure you use your own field names in place of the ones I've made up. If you're using ADO instead of DAO, you'll need to change the code for the DISPLAY action accordingly; use VBA's Help for more information. You can also search these newsgroups for more information; all of these topics are discussed frequently. Hopefully this will get you started. Carl Rapson "MEG" wrote in message ... Thank you for the response. Since I sent this post, I met with the user. The access database is used after doing some functions in another application. This application has functionality to call the access database with a command line. Therefore, to make it easier for the user, I'm looking to incorporate the command line into the access database. I have started this process and I'm passing the following: FORM ACCOUNT ACTION FORM can be one of three (FORM1, FORM2, FORM3) ACCOUNT is the ACCOUNT number they want to add or display a record ACTION is the whether to ADD a record for the ACCOUNT or DISPLAY a record for the ACCOUNT I've successfully broken the command line into the 3 above parts. What I could use help with is the code to open the form and do the two actions. THANKS, MEG "Carl Rapson" wrote: That would be my recommendation, as it gives you only one form to maintain. You can pass a string such as "ADD" or "REVIEW" to the form when it opens (in the DoCmd.OpenForm call), and in the Form_Open or Form_Load event take appropriate steps depending on which string was passed. Carl Rapson "MEG" wrote in message ... My question relates to best methods. The application has a "swithboard" type form that allows the user to: 1) ADD a test 2) REVIEW a test (allows for changing the data) Is it best (or is there a great technique or tip) to use one FORM for this and set it to either do an ADD or REVIEW based on the call from the "switchboard" form. THANKS, MEG |
#5
|
|||
|
|||
Form used for ADD and CHANGE?
After you've parsed the command line (I assume that's what you meant by
'broken'), open the form as follows: DoCmd.OpenForm strForm,,,,,,strAccount & "+" & strAction This assumes: 1. strForm contains the name of the form to open 2. strAccount contains the Account number. The syntax above assumes the account number is a string; if it's numeric, remove the single quotes: DoCmd.OpenForm strForm,,,,,,strAccount & "+" & strAction 3. strAction contains the action to be performed Note that I'm concatenating the Account and Action strings together, separating them by a "+" just so we have something to parse them by. If there is a chance that the Account string will contain a plus sign, you can use any other character you wish to separate the two strings. In the form's Open event, parse the Account and Action strings into module-level variables (declared at the top of the module, before the first procedure): Dim strAccount As String ' if Account is numeric, declare as follows ' Dim lngAccount As Long Dim strAction As String ... Private Sub Form_Open() strAccount = Left(Me.OpenArgs, InStr(Me.OpenArgs, "+") - 1) strAction = Right(Me.OpenArgs, Len(Me.OpenArgs)-InStr(Me.OpenArgs, "+")) End Sub In the form's Load event, check the action as follows: If Me.OpenArgs = "ADD" Then ' Add a new record for the Account DoCmd.GotoRecord , , acNewRec Me![Account] = strAccount ElseIf Me.OpenArgs = "DISPLAY" Then ' Locate the record for this Account Dim rs as Recordset set rs = Me.RecordsetClone rs.FindFirst "[Account] = '" & strAccount & "'" ' if Account is numeric, use the following line instead: ' rs.FindFirst "[Account]=" & lngAccount If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark Else ' Account not found! End If rs.Close Set rs = Nothing Else ' In case there is another possibility for the Action End If Understand, these are just some ideas and I haven't actually tested the code above. Be sure you use your own field names in place of the ones I've made up. If you're using ADO instead of DAO, you'll need to change the code for the DISPLAY action accordingly; use VBA's Help for more information. You can also search these newsgroups for more information; all of these topics are discussed frequently. Hopefully this will get you started. Carl Rapson "MEG" wrote in message ... Thank you for the response. Since I sent this post, I met with the user. The access database is used after doing some functions in another application. This application has functionality to call the access database with a command line. Therefore, to make it easier for the user, I'm looking to incorporate the command line into the access database. I have started this process and I'm passing the following: FORM ACCOUNT ACTION FORM can be one of three (FORM1, FORM2, FORM3) ACCOUNT is the ACCOUNT number they want to add or display a record ACTION is the whether to ADD a record for the ACCOUNT or DISPLAY a record for the ACCOUNT I've successfully broken the command line into the 3 above parts. What I could use help with is the code to open the form and do the two actions. THANKS, MEG snipped |
Thread Tools | |
Display Modes | |
|
|