Do.cmd to open report

pwicr

Registered User.
Local time
Today, 00:27
Joined
Sep 22, 2011
Messages
144
I'm trying to get my VB written to ONLY open a report if the DriverID is "SELECT CLASSIC CARRIERS". This is what I have...

Private Sub btnSHIP_Click()
On Error GoTo Err_btnSHIP_Click

Dim stLinkCriteria As String
Dim DriverName As String

DriverName = Me.DRVID

If Me.Dirty Then Me.Dirty = False

stLinkCriteria = "[Serial Number] = " & Chr(34) & Me![Serial number] & Chr(34)
DoCmd.OpenReport "rptSINGLEUNITSHIP", acViewPreview, , stLinkCriteria
DoCmd.OpenReport "rptSINGLESELECTBILLOFLADING", acViewPreview, , "DRIVERNAME = '" & "SELECT CLASSIC CARRIERS" & "'"

Exit_btnSHIP_Click:
Exit Sub

Err_btnSHIP_Click:
MsgBox Err.Description
Resume Exit_btnSHIP_Click
End Sub

It is opening regardless of who the driver is...

banginghead.gif
 
Code:
If DRVID = "SELECT CLASSIC CARRIERS" Then
    DoCmd.OpenReport "rptSINGLESELECTBILLOFLADING", acViewPreview, , "DRIVERNAME = 'SELECT CLASSIC CARRIERS'"
End If
 
Hmmm...I must have something wrong because it didn't work...

Private Sub btnSHIP_Click()
On Error GoTo Err_btnSHIP_Click

Dim stLinkCriteria As String

If Me.Dirty Then Me.Dirty = False

stLinkCriteria = "[Serial Number] = " & Chr(34) & Me![Serial number] & Chr(34)

DoCmd.OpenReport "rptSINGLEUNITSHIP", acViewPreview, , stLinkCriteria

If DRVID = "SELECT CLASSIC CARRIERS" Then
DoCmd.OpenReport "rptSINGLESELECTBILLOFLADING", acViewPreview, , "DRIVERNAME='SELECT CLASSIC CARRIERS'"
End If

Exit_btnSHIP_Click:
Exit Sub

Err_btnSHIP_Click:
MsgBox Err.Description
Resume Exit_btnSHIP_Click
End Sub

It isn't opening the bill of lading at all...
 

Users who are viewing this thread

Back
Top Bottom