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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '13': Type mismatch 1

Status
Not open for further replies.

TriniGal

Programmer
Sep 28, 2005
84
US
Hello,

Can someone tell me what I'm doing wrong, or please help me.

Code:
Private Sub cmdOK_Click()

    With Forms("frmADD_LEAK_FORM")
        [highlight].Filter = "COMMUNITY= '" & Me.COMMUNITY & "'" And Forms.frmADD_LEAK_FORM.frmADD_LEAK_SUBFORM.Form.LEAKID = Me.LEAKID[/highlight]
        .FilterOn = True
    End With
    DoCmd.Close acForm, Me.Name
    
End Sub

I have a form (frmAdd_Leak), that has a subform (frmAdd_Leak_Subform), they
are attached by txtCommunity. I have another form (frmEdit) that is attached
to the subform by txtLeakID.

When the user wants to edit existing data, they click on the Edit button,
and the frmEdit open where they enter their name and todays date. I want
when they click the okay button, that second form closes and then frmAdd_Leak
is filtered to the txtcommunity, and the frmAdd_Leak_Subform is filtered to
the txtLeakID.

Please help.

Thanks in advance.


 
Don't you need the correct quote marks around the second part of the where statement? Something like:

.Filter = "COMMUNITY= '" & Me.COMMUNITY & "'" And Forms.frmADD_LEAK_FORM.frmADD_LEAK_SUBFORM.Form.LEAKID = '" & Me.LEAKID & "';"

 
Addy,

Thanks for your response. That didn't work, I'm still getting the same error. I'm new at this, so, pretty much what I typed is a guess. It all works up til...

Code:
Private Sub cmdOK_Click()

    With Forms("frmADD_LEAK_FORM")
        .Filter = "COMMUNITY= '" & Me.COMMUNITY & "'" 
        .FilterOn = True
    End With
    DoCmd.Close acForm, Me.Name
    
End Sub

Its when I add....

Code:
And Forms.frmADD_LEAK_FORM.frmADD_LEAK_SUBFORM.Form.LEAKID = "'" & Me.LEAKID & "'"

I get the error. I can filter the form, but I'm not able to filter the subform.

Any other suggestions...Thanks.
 
How are ya TriniGal . . .

. . . and this:
Code:
[blue]   Dim frm As Form, sfrm As Form
 
   Set frm = Forms!frmADD_LEAK_FORM
   Set sfrm = frm!frmADD_LEAK_SUBFORM.Form
    
   frm.Filter = "[COMMUNITY] = '" & Me.COMMUNITY & "'"
   frm.FilterOn = True
   sfrm.Filter = "[LEAKID] = " & Me.LEAKID
   sfrm.FilterOn
    
   Set sfrm = Nothing
   Set frm = Nothing
   DoCmd.Close acForm, Me.Name[/blue]
Double check you form names: [blue]frmAdd_Leak[/blue], [blue]frmADD_LEAK_FORM[/blue] . . . which one?

Calvin.gif
See Ya! . . . . . .
 
perhaps something like this ?
With Forms("frmADD_LEAK_FORM")
.Filter = "COMMUNITY= '" & Me.COMMUNITY & "'"
.FilterOn = True
With !frmADD_LEAK_SUBFORM.Form
.Filter = "LEAKID = '" & Me.LEAKID & "'"
.FilterOn = True
End With
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ace,

Thank you soooooooooooooo....much for your help, it worked perfectly. Here's a star. I have been working on this particular problem for quite awhile.

PHV and Addy, thanks also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top