Filtering on a field in a subform

R

Ricter

Ok, here it is Steve. I can replace TransType with Me. TransType, but that
didn't solve the problem.

TransType combobox:
Row Source Type: Value List
Row Source: "Entry";"Export";"Refund";"Amend";"Other"


Private Sub Form_Current()
Form.Refresh
If Me.TransType = "Export" Or Me.TransType = "Amend" Or Me.TransType =
"Refund" Then
ShipDate.Visible = False
DutyCharge.Visible = False
Check63.Visible = False
Check65.Visible = False
Me!subTariffs.Visible = False
Me!subInvoices.Visible = False
Me!subAmendments.Visible = False
Me!Text26.Visible = False
Me!Text33.Visible = False
Me!Text35.Visible = False
Me!Label38.Visible = False
Else
ShipDate.Visible = True
DutyCharge.Visible = True
Check63.Visible = True
Check65.Visible = True
Me!subTariffs.Visible = True
Me!subInvoices.Visible = True
Me!subAmendments.Visible = True
Me!Text26.Visible = True
Me!Text33.Visible = True
Me!Text35.Visible = True
Me!Label38.Visible = True

End If
Form.Refresh
End Sub
 
S

Steve Schapel

Rick,

I'm sorry, I don't know what exactly is causing this problem. Maybe
someone else might see it. All I would know what to do at this point is
some experimenting by way of trouble-shooting. The first thing I would
try is a simplified version of the code, in an attempt to pin-point
where it is failing. I don't understand what Form.Refresh is supposed
to do in this context, and I would remove that. And then, try something
like this...
Private Sub Form_Current()
If Me.TransType = "Export" Or Me.TransType = "Amend" Or Me.TransType
= "Refund" Then
MsgBox "yes"
Else
MsgBox "no"
End If
End Sub

So what to do next would depend on whether you still get the error like
this.

But, by way of simplifying the code, I offer this suggestion...
Private Sub Form_Current()
Dim TypeTest As Boolean
TypeTest = Not (Me.TransType = "Export" Or Me.TransType = "Amend"
Or Me.TransType = "Refund")
Me.ShipDate.Visible = TypeTest
Me.DutyCharge.Visible = TypeTest
Me.Check63.Visible = TypeTest
Me.Check65.Visible = TypeTest
Me!subTariffs.Visible = TypeTest
Me!subInvoices.Visible = TypeTest
Me!subAmendments.Visible = TypeTest
Me!Text26.Visible = TypeTest
Me!Text33.Visible = TypeTest
Me!Text35.Visible = TypeTest
Me!Label38.Visible = TypeTest
End Sub
 
R

Ricter

Steve, I'm gonna work through it like you recommend. Thanks for the
simplified code snippet there, I've learned a couple of new things in this
thread!

Rick
 
R

Ricter

Oh brother. I finally stumbled on the solution. At some point during this
process of working out the filter with you, I eliminated the quotes around
tblShipments in Me.RecordSource. Put the quotes back in and it's now working
fully. Filter working, turning filter off working. Wow.

Steve, I owe you one.
 
S

Steve Schapel

Rick,

Looking back to an earlier post of yours, I see where you had this in
the code you posted, and I missed it, so sorry I didn't pick it up at
that stage.

Anyway, great news. Best wishes for the rest of your project.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top