Docmd.open

Taff

Registered User.
Local time
Today, 17:06
Joined
Feb 3, 2004
Messages
158
Hi all,

I have a form with a command button on and the following on the OnClick Event of the command button:-

Code:
Private Sub CmdEditLearnerProduct_Click()
On Error GoTo Err_CmdEditLearnerProduct_Click
    
If Me.List3.ListCount = 0 Then
DoCmd.RunMacro "NoFunding" 'Displays message if no Funding to View
DoCmd.CancelEvent
Else
    If Me.List3.ListCount <> 0 And Me.List3.ItemsSelected.Count = 0 Then
    DoCmd.RunMacro "msgboxSelectProduct" 'Displays message if No Funding Selected
    DoCmd.CancelEvent
    Else
   
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FrmEditProduct"
    
   stLinkCriteria = "[learn_id] = '" & Me.List3.Column(0) & "'" & " and [provi_id] = '" & Me.List3.Column(1) & "'" & " and [lprog_id] = '" & Me.List3.Column(2) & "'" & " and [ContractID] = '" & Me.List3.Column(3) & "'" & " and [ProductID] = '" & Me!List3.Column(4) & "'" & " and [ClaimDate] = '" & Me!List3.Column(6) & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CmdEditLearnerProduct_Click:
    Exit Sub

Err_CmdEditLearnerProduct_Click:
    MsgBox Err.Description
    Resume Exit_CmdEditLearnerProduct_Click
    
    End If
End If

End Sub

I get the message:-

The openform action was cancelled

When i remove the following line it works okay.

Code:
& " and [ClaimDate] = '" & Me!List3.Column(6) & "'"

The field ClaimDate is a date field in the format dd/mm/yyyy.

Any Ideas,

Thanks

Anthony
 
Change the ' (for a string) to # (for a date)

Regards

Ps. Why the runmacro thing? Use msgbox instead ... dont use macro's come on....
 
thanks

Thanks namliam works great,


namliam said:
Ps. Why the runmacro thing? Use msgbox instead ... dont use macro's come on....
Will do. :)

Ant.
 

Users who are viewing this thread

Back
Top Bottom