View Full Version : form linking


xveganx007
04-04-2000, 06:18 AM
when opening a new form from a command button, how can i link the forms using 2 data fields here is the code i have so far (linking just one of the fields, this was made using the command button wizard, i have little vba knowledge):


Private Sub Change_Data_Click()
On Error GoTo Err_Change_Data_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "QA SALP Data - Add screen"

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

Exit_Change_Data_Click:
Exit Sub

Err_Change_Data_Click:
MsgBox Err.Description
Resume Exit_Change_Data_Click

End Sub

the other field is in the same table and is called INDXITMNO
any help would be greatly appreciatted

nick
04-04-2000, 07:31 AM
Change the line

stLinkCriteria = "[AUDIT_NO]=" & "'" & Me![AUDIT_NO] & "'"

to

stLinkCriteria = "[AUDIT_NO]=" & "'" & Me![AUDIT_NO] & "' and [INDXITMNO] = '& me![indxitmno] &"'"

where the value on the form is me![indxitmno]

xveganx007
04-04-2000, 09:43 AM
Thanks Nick,
it work great