carlchapman
Registered User.
- Local time
- Today, 04:06
- Joined
- Jul 25, 2006
- Messages
- 29
hi,
Private Sub Command43_Click()
On Error GoTo Err_Command43_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddCnt"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command43_Click:
Exit Sub
Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click
End Sub
This is access built in open form command button. This works fine for opening the default form, but what i need to do is to open the form, but load the record into the form from which the command button was clicked.
Basicaly, at present state i have a parent form, with details on companies. Then i have incorporated a subform that lists all staff relating to the company. i have made the sub form to display as continual forms. For each record (staff member) their is a command button which open a form for viewing staff details. Of course, this only opens the default so i have to search for the staff which i already have the details for in the previous form. What a waste of time searching yet again for the staff member. So i need to sum how grab the primary key field from the sub form , so when the Onclick command button use the key, to pull up the record in the staff form.
The best two ways i can think of are (please bare with me i am new to access and VBA) is to A) create a temp table with the key, and run a query to give the staff form the required fields or B) sum how place the table primary key field into a global varible, and as a default in the staff form, to search for a "globle variable" to give the desired result, then have a query (or what ever method used to fill a forms fields).
the latter i think is the desired approach, however i am not the expert. This is why i need your help, any VBA you can pass my way to perform this task would also be appreciated
cheers
Private Sub Command43_Click()
On Error GoTo Err_Command43_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAddCnt"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command43_Click:
Exit Sub
Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click
End Sub
This is access built in open form command button. This works fine for opening the default form, but what i need to do is to open the form, but load the record into the form from which the command button was clicked.
Basicaly, at present state i have a parent form, with details on companies. Then i have incorporated a subform that lists all staff relating to the company. i have made the sub form to display as continual forms. For each record (staff member) their is a command button which open a form for viewing staff details. Of course, this only opens the default so i have to search for the staff which i already have the details for in the previous form. What a waste of time searching yet again for the staff member. So i need to sum how grab the primary key field from the sub form , so when the Onclick command button use the key, to pull up the record in the staff form.
The best two ways i can think of are (please bare with me i am new to access and VBA) is to A) create a temp table with the key, and run a query to give the staff form the required fields or B) sum how place the table primary key field into a global varible, and as a default in the staff form, to search for a "globle variable" to give the desired result, then have a query (or what ever method used to fill a forms fields).
the latter i think is the desired approach, however i am not the expert. This is why i need your help, any VBA you can pass my way to perform this task would also be appreciated

cheers