requery I think

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a form with 2 combo boxes in header afterupdate of 2nd combobox I
would like the query that first combo is based on to run so data shown in
first combo box is updated
I think I need to use requery but can't get it to work
Thanks
tk
 
Tina,
On AfterUpdate.... (use your names)
Me.cboCombo1.Requery

Your post is a bit confusing though... The usual process is to select a
value from Combo1 (ex. cboState), Requery Combo2, and then select a City
from Combo2 (ex. cboCity).
It's more logical to refer to the value in Combo1 being used to
update/filter Combo2... not 2 updating 1.
But that's not critical, just a bit unusual...
hth
Al Camp
 
Hi Lynn
I will try to explain
Combox 1 has a list of batch numbers where job is null from a query called
batch no afterupdate the form based on table (derbatchno2) will goto
recordset of this batch number the second combobox has list of available jobs
afterupdate of this combox the the job field in form is updated with the job
number
the comboxes are then set to null for next selection .
So when select combox 1 the batch number originally selected should nolonger
be available as job is nolonger is null
if close form and reopen this is case but other wise it still shows
My codes so far are as follows
Private Sub combo1_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[BatchNo] = """ & Me.combo1 & """"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Combo2_AfterUpdate()
If IsNull(Me.combo1) Then
MsgBox "please select batch number first"
Me.Combo2 = Null
Exit Sub
Else
Me.Job = Me.Combo2
Me.CycleCount = Me.Combo2.Column(1)
Me.ExpiryMonth = DateAdd("m", Me.CycleCount, Me.StartMonth)
Me.TimeStamp = Now
End If
Me.combo1 = Null
Me.Combo2 = Null
End Sub
Hope this explains what i am trying to do
thanks for your time
tk
 
Well, like Al and I both said, it's a bit strange but you could try doing
this:

Private Sub Combo2_AfterUpdate()
If IsNull(Me.combo1) Then
MsgBox "please select batch number first"
Me.Combo2 = Null
Exit Sub
Else
Me.Job = Me.Combo2
Me.CycleCount = Me.Combo2.Column(1)
Me.ExpiryMonth = DateAdd("m", Me.CycleCount, Me.StartMonth)
Me.TimeStamp = Now
Me.Combo1.Requery
End If
Me.combo1 = Null
Me.Combo2 = Null
End Sub


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



tina said:
Hi Lynn
I will try to explain
Combox 1 has a list of batch numbers where job is null from a query called
batch no afterupdate the form based on table (derbatchno2) will goto
recordset of this batch number the second combobox has list of available
jobs
afterupdate of this combox the the job field in form is updated with the
job
number
the comboxes are then set to null for next selection .
So when select combox 1 the batch number originally selected should
nolonger
be available as job is nolonger is null
if close form and reopen this is case but other wise it still shows
My codes so far are as follows
Private Sub combo1_AfterUpdate()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[BatchNo] = """ & Me.combo1 & """"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Combo2_AfterUpdate()
If IsNull(Me.combo1) Then
MsgBox "please select batch number first"
Me.Combo2 = Null
Exit Sub
Else
Me.Job = Me.Combo2
Me.CycleCount = Me.Combo2.Column(1)
Me.ExpiryMonth = DateAdd("m", Me.CycleCount, Me.StartMonth)
Me.TimeStamp = Now
End If
Me.combo1 = Null
Me.Combo2 = Null
End Sub
Hope this explains what i am trying to do
thanks for your time
tk

Lynn Trapp said:
Well, normally you would requery the 2nd combobox in the Change event of
the
first. I can't quite visualize what you are trying to do by basing a
first
combobox on a second.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html
 
Back
Top