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!

Opening a Form with 2 fields as source 1

Status
Not open for further replies.

rlpenman1

Programmer
Jan 29, 2004
10
US
I am trying to have my button call up multiple fields from the same table my code looks like this now and I am getting a type mismatch error. The button works just fine when I try to pull from only one field.

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String

stDocName = "EmployeeAdd"

stLinkCriteria = "[EmpLast]=" & "'" & Me![EmpLast] & "'"
stLinkCriteria2 = "[OrgCode]=" & "'" & Me![Orgcode] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria And stLinkCriteria2
Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub

Thank You
Ryan
 
Hi!

Several ways to do this, point is to concatinate/send one criteria string to the form, for instance:

[tt] stLinkCriteria = "[EmpLast]=" & "'" & Me![EmpLast] & _
"' And [OrgCode]='" & Me![Orgcode] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria[/tt]

To see what this produces, try a Debug.Print stLinkCriteria, hit CTRL+G and check the results. The where condition is a valid where clause of an sql statement without the keyword Where (from help files)

Roy-Vidar
 
Roy that was the trick. I thank you, hopefully one of these days I will understand when to use quotes :) Thank you again

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top