Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PASSING VALUE FROM ONE FORM TO ANOTHER

Status
Not open for further replies.

kaniz

Technical User
Jan 17, 2001
38
CA
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 .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top