I have search form. When the user cliks any of the record I would like to be able to go back to main form with the record they selected. I can't seem to be able to do it with the following code. My main form has two subforms. The main form is boud to 3 tables since there is two subforms.
I just don't know how to set the control source of the main form to the record they selected on the search form
Private Sub Form_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim strRecordSource As String
strRecordSource = "Select * from EMPLOYEE WHERE ID = " & Forms!SEARCH!SEARCHSUBFORM.FORM.ID
Msg = "Do you want Edit this Record?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Edit Record" ' Define title.
Help = "access.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
Forms!EMPLOYEE.SetFocus
Forms!EMPLOYEE.AllowEdits = True
Forms!EMPLOYEE.RecordSource = strRecordSource
MyString = "Yes" ' Perform some action.
Else ' User chose No.
MyString = "No" ' Perform some action.
' MsgBox "user selected no"
End If
End Sub
thanks everyone for any suggestions. I have changed the above code in so many ways .
I just don't know how to set the control source of the main form to the record they selected on the search form
Private Sub Form_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim strRecordSource As String
strRecordSource = "Select * from EMPLOYEE WHERE ID = " & Forms!SEARCH!SEARCHSUBFORM.FORM.ID
Msg = "Do you want Edit this Record?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Edit Record" ' Define title.
Help = "access.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
Forms!EMPLOYEE.SetFocus
Forms!EMPLOYEE.AllowEdits = True
Forms!EMPLOYEE.RecordSource = strRecordSource
MyString = "Yes" ' Perform some action.
Else ' User chose No.
MyString = "No" ' Perform some action.
' MsgBox "user selected no"
End If
End Sub
thanks everyone for any suggestions. I have changed the above code in so many ways .