Run time error 424

Switch

Registered User.
Local time
Today, 21:58
Joined
Feb 16, 2012
Messages
16
It's been a long week and i'm falling asleep at my desk. i keep getting this error with this code, any ideas? :banghead:


Code:
Private Sub Command63_Click()

DoCmd.OpenForm "frm_history"
[COLOR="Red"]frm_history.Filter = "siteID = " & Me.siteID & "'"[/COLOR]
frm_history.FilterOn = True

End Sub

Using access 2010 and cheers
 
Switch, Welcome to AWF.. :)

You seem to be missing a Single quote after the = sign..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history"
    frm_history.Filter = "siteID = [COLOR=Red][B]'[/B][/COLOR]" & Me.siteID & "'"
    frm_history.FilterOn = True
End Sub
 
just tried it, i still get the same error, thanks tho

Switch, Welcome to AWF.. :)

You seem to be missing a Single quote after the = sign..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history"
    frm_history.Filter = "siteID = [COLOR=Red][B]'[/B][/COLOR]" & Me.siteID & "'"
    frm_history.FilterOn = True
End Sub
 
What type is Site ID? If it is Number then it does not need to be enclosed in single quotes.. Also is this button filtering the same form? Then use Me. instead of FormName..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history"
    Me.Filter = "siteID = " & Me.siteID 
    Me.FilterOn = True
End Sub
 
just tried it, siteID is a number, but i'm still getting the same error, cheers

What type is Site ID? If it is Number then it does not need to be enclosed in single quotes.. Also is this button filtering the same form? Then use Me. instead of FormName..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history"
    Me.Filter = "siteID = " & Me.siteID 
    Me.FilterOn = True
End Sub
 
Right, How did I miss that.. Try this..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history", OpenArgs:=Me.siteID 
End Sub
In your Form frm_history's OnOpen event place this..
Code:
Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
        Me.Filter = "siteID = " & Me.OpenArgs
        Me.FilterOn = True
    End If
End Sub
PS: Just a suggestion, in future could you please also inclde the Error description? That will help a lot.. We all cannot remeber all Error numbers and their associated description.. would be a great help.. :)

attachment.php
 
well, the error message has gone, the data in the subform still doesn't open on the record, but that's another issue, cheers

Right, How did I miss that.. Try this..
Code:
Private Sub Command63_Click()
    DoCmd.OpenForm "frm_history", OpenArgs:=Me.siteID 
End Sub
In your Form frm_history's OnOpen event place this..
Code:
Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
        Me.Filter = "siteID = " & Me.OpenArgs
        Me.FilterOn = True
    End If
End Sub
PS: Just a suggestion, in future could you please also inclde the Error description? That will help a lot.. We all cannot remeber all Error numbers and their associated description.. would be a great help.. :)
 

Users who are viewing this thread

Back
Top Bottom