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

sub form not linking

Status
Not open for further replies.

Mary10k

IS-IT--Management
Nov 8, 2001
103
US
I have an Access form with a button on it that opens a sub form. I cannot get the sub form to open linking to the record id on the first form. Any suggestions?

Here is the code I use to open the sub form:
Private Sub Command178_Click()
On Error GoTo Err_Command178_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Contact"

stLinkCriteria = "[EMPI]=" & "'" & Me![EMPI] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command178_Click:
Exit Sub

Err_Command178_Click:
MsgBox Err.Description
Resume Exit_Command178_Click

End Sub
 
I think you have altered the code. try changing to the original position.
Code:
stLinkCriteria = "[EMPI]=" & "'" & Me![EMPI] & "'"
Code:
stLinkCriteria = "[EMPI]=" & Me![EMPI]

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Hello,
Thank you for your help. I tried the modifications listed above and they are not working. Any other suggestions?

Thank you.
 
Do you mean that the form is not opening?
It is opening and not shows the correct record?
It is opening and shows nothing?
Giving any error message?

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Hello,
The form opens, but it is not linked to any record from the main form. When it opens, it is just a text box.

No errors are happening.
Thanks,
 
I think you have set the new form's DataEntry=Yes. In this case it will open only in the new record mode.
Change to
Form Properties > Data tab > DataEntry=No


Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top