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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Form Question? 1

Status
Not open for further replies.

Heidi03

Programmer
Feb 27, 2004
1
US
I am quite new to this, I picked it up yesterday. My boss wants me to creat a database, and so far I have done good. I am having trouble entering data on form. When the db starts up you have a record on the master, and click a button to add an inspection to that master which opens another form. How do I get the ID (key field) to show up on the new inspection form that opens linking it to the master?

Thanks in Advance!
heidi
 
Assuming Form 1 = Master and Form 2 = NewInspectionForm and the key was called MasterKey you could add the following code to Form 1

Private Sub btn_OpenInspectionForm_Click()

DoCmd.OpenForm "NewInspectionForm", , , , , , MasterKey.Value

End Sub

And then add this code to the Form_Open even on your NewInspectionForm.

Private Sub Form_Open(Cancel As Integer)

If (IsNull(Me.OpenArgs)) Then
DoCmd.CancelEvent
Else
txt_ShowMastersKeyfield.Value = Me.OpenArgs
End If

End Sub

This will place the MasterKey.value in the textbox 'ShowMasterKeyField'

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top