PDA

View Full Version : Solved: Multiple stLinkCriteria



JustJerry
01-05-2006, 03:16 PM
Hello and Happy New Year.

From my Start Form, I want to open up my Main Form based on three choices selected in the Start Form and display the results for the choices selected. This is the code I am attempting to use:

Private Sub OpenMainForm_Click()
On Error GoTo Err_OpenMainForm_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMainMile"

stLinkCriteria = "[TruckID]=" & Me![cboTruckID] And "[Month]=" & Me![cboMonth] And "[Year]=" & Me![Year]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_OpenMainForm_Click:
Exit Sub
Err_OpenMainForm_Click:
MsgBox Err.Description
Resume Exit_OpenMainForm_Click

End Sub

When I attempt to click on the command button which runs this code, I get an error that says:

Type Mismatch

[Truck ID], [cboTruckID], and both [Year]'s, are Fixed numeric fields, and [cboMonth] and [Month] are text fields.

Can someone please send me in the right direction

JustJerry
01-06-2006, 10:27 AM
I solved my problem. I ended up changing everything to a text field, and also found I had omitted the "&" sign in a few places.
stLinkCriteria = "[Month]=" & "'" & Me![cboMonth] & "'" & "And [TruckID]=" & "'" & Me![cboTruckID] & "'" & "And [Year]=" & "'" & Me![Year] & "'"