Don't shoot me just yet... (1 Viewer)

Darrell

Registered User.
Local time
Today, 01:51
Joined
Feb 1, 2001
Messages
196
After spending most of the day searching the forums I've given up and decided to ask for help, so please be gentle with me.

I have a form which uses two dynamic combo boxes to filter for a specific record. This is pretty much EXACTLY the same as the one in the MS Solutions database (Edit Products form) which in fact, turns out to have the same problem.

The form works fine when it is first opened, and when I select a value from combo box A, it filters combo box B as I want and when I select a value from combo box B, the form displays the record for this combination.

The problem is when I try to select a new value from combo box A. Again, it filters combo box B correctly, but it doesn't change my record after the value of combo box B is selected.

Can someone please shed some light on why they think this may be occuring.

Thanks

dh
 

daveUK

Registered User.
Local time
Today, 01:51
Joined
Jan 2, 2002
Messages
234
requery???

It sounds like combo box B isn't being requeried. Try requering it on the After Update event.

If you can't work it out, post the code and someone might be able to help.

Dave
 

Darrell

Registered User.
Local time
Today, 01:51
Joined
Feb 1, 2001
Messages
196
:confused: Unfortunately I can't work it out...so here you go

The two combo boxes are named SelectSAPNumber and SelectMachine, and are chosen in that order in the form.
The controls in the detail section of the form are SAPNumber, Machine, Description, and SpecRate



Private Sub Form_AfterUpdate()
' Requery SelectMachine combo box.
Me!SelectMachine.Requery
End Sub



Private Sub SelectSAPNumber_AfterUpdate()
' Enable and requery SelectMachine combo box.
' Disable controls in detail section.
Me!SelectMachine.Enabled = True
Me!SelectMachine.Requery
EnableControls Me, acDetail, False
Me!Description.Visible = False
End Sub


Private Sub SelectMachine_AfterUpdate()
' Find record for Machine selected in SelectMachine combo box.
' Enable controls in detail section
' Go to SpecRate.
DoCmd.ApplyFilter , "Machine = Forms!EditProducts!SelectMachine And SAPNumber = Forms!EditProducts!SelectSAPNumber"
EnableControls Me, acDetail, True
Me!Description.Visible = True
Me!Description.Enabled = False
Me!SpecRate.SetFocus
End Sub


Private Sub SelectMachine_BeforeUpdate(Cancel As Integer)
If IsNull([SelectMachine]) Then
MsgBox "You must select a Machine."
Cancel = True
End If
End Sub


Thanks to anyone who can help with this...


dh
 

coryt

Registered User.
Local time
Yesterday, 20:51
Joined
Jun 13, 2003
Messages
82
Try this adding the code in red.

Private Sub SelectMachine_AfterUpdate()
' Find record for Machine selected in SelectMachine combo box.
' Enable controls in detail section
' Go to SpecRate.
DoCmd.ApplyFilter , "Machine = Forms!EditProducts!SelectMachine And SAPNumber = Forms!EditProducts!SelectSAPNumber"
EnableControls Me, acDetail, True
Me!Description.Visible = True
Me!Description.Enabled = False
me.form.requery
Me!SpecRate.SetFocus
End Sub

Not 100 sure it will work, but it's worht a try! Let me know either way. I'm still learning.
 

Darrell

Registered User.
Local time
Today, 01:51
Joined
Feb 1, 2001
Messages
196
Gaaaaaaaaargh!!

Thanks coryt. That did indeed work.

I can't believe I never tried requerying the form....doh!!

oh well.

Cheers :)

dh
 

Darrell

Registered User.
Local time
Today, 01:51
Joined
Feb 1, 2001
Messages
196
Ooops I forgot to add that I had to move that line.

It now looks like this

me.form.requery
DoCmd.ApplyFilter , "Machine = Forms!EditProducts!SelectMachine And SAPNumber = Forms!EditProducts!SelectSAPNumber"
EnableControls Me, acDetail, True
Me!Description.Visible = True
Me!Description.Enabled = False
Me!SpecRate.SetFocus
End Sub

dh
 

coryt

Registered User.
Local time
Yesterday, 20:51
Joined
Jun 13, 2003
Messages
82
COOL!!!!! I can't believe I was actually able to help for a change!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom