Field on Filtered Subform doesn't respond to event procedure

  • Thread starter Jeff E via AccessMonster.com
  • Start date
J

Jeff E via AccessMonster.com

I have a form (MAIN) that has a Subform (SUBFORM) and a combo Box (CLIENTNAME)
.. The SubForm is a datasheet view of serial numbers. When the form opens up,
it list all the serial numbers for all Clients. When I pick a client from
the combo box, it filters the subform to list only the serial numbers for
that specific client. Code below:

Dim FiltVal As String

FiltVal = Me.Combo3.Value

Me.Subform.Form.Filter = "CLIENTNAME='" & FiltVal & "'"
Me.Subform.Form.FilterOn = True

This works just fine (it is for background info only).

Each serial number has a model number. Each model number has specific
information for that model number. For example; if model number is PEN, the
specifics would be barrell width and lenght, activation type, ink color,
inkrefilltype. If modelnumber is PENCIL, the specifics would be barrell
width and lenght, leadweight, erasertype, etc.

On the subform in the Serial number field, I made a it so that if you double
click a serial number, a form will open up that has information for that
specific model number and serial number. That is to say if you double click
the serial number 0001 that is a model number PEN, a VIEW_PEN_SPECS_FORM will
open, if SN 0001 was a model number PENCIL, a VIEW_PENCIL_SPECS_FORM would
open. This works too (sort of, as I will ask below). The code is:

Me.Filter = "SerialNumber=" & Me.SerialNumber.Value

If Me.ModelNumber.Value Like "PEN" Then
DoCmd.OpenForm "VIEW_PEN_SPECS_FORM", , , Me.Filter
Else
DoCmd.OpenForm "VIEW_PENCIL_SPECS_FORM", , , Me.Filter
End If

The problem is that this code works as long as the whole list is present.
Once I use the combo box and filter the serial numbers for a specific client,
then double click a serialnumber from the subform, it throws up a "Enter
SerialNumber Value" dialog box. What's the deal? Why can't it use the value
like it did when the list was unfiltered?

So then I enter in the serial number manually in the dialog box and it opens
up a blank record on the VIEW_PEN_SPECS_FORM regardless of whether it is a
PEN or PENCIL.

I am a fairly good user of Access and VB but I can't see why it would before
the filter but not after. Please help.
 
J

Jeff E via AccessMonster.com

Figured it myself by looking at other threads and filling in the blanks.
Code should look like this:

If Me.ModelNumber.Value Like "PEN" Then

DoCmd.OpenForm "VIEW_PEN_SPECS_FORM", , , WHERECONDITION:="SerialNumber=" &
Me.SerialNumber.Value

Else

DoCmd.OpenForm "VIEW_PENCIL_SPECS_FORM", , , WHERECONDITION:="SerialNumber="
& Me.SerialNumber.Value

End If

Thanks to everyone that keeps this forum running. Without you, I wouldn't be
the Database Master in my bosses eyes.
 

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