Combo box query problem

Pusher

BEOGRAD Put
Local time
Today, 19:47
Joined
May 25, 2011
Messages
230
Hi y'all,
I have a combo box that controls another combo box thru a query. When I use the form to enter the first combo box I can only select the first of many choices in the second combo box. What’s the problem? I see the other choices but can’t select them, when I click it I just return to the first choice.

Also how can I make my form go to the last record when I enter it?

Thanks a bunch
 
Send a short example of your MDB (access 2000 or 2002-2003).
Last record, on Sub Form Load.
DoCmd.GoToRecord,,acLast
 
Hmm I just made it again and it works fine... the only difference is that row source in the NOT working one is connected to the query and the other one has the code in the raw source…
 
Look at "Demo4ComboA2000.mdb" (attachment, zip).
It can help you, open form and see.
Look at TABLES, and RELATIONSHIPS.
 

Attachments

Last edited:
I got the Requery :) thanks- that the query is redone when i change the combo box - but how can i make the requery happen when i change to different records automatically without clicking the combo box in that specific record?
 
On Sub On_Current put
Requery on Combo1, and Requery on Combo2,
and empti Combo1 and Combo2.
 
Can you write me the exact code please :(
Here is my code
Option Compare Database

Private Sub DanasnjiDatum_Click()
On Error GoTo Err_DanasnjiDatum_Click

Me.DATUM_IZVESTAJA = Date
Call DATUM_IZVESTAJA_AfterUpdate

DoCmd.RunCommand acCmdApplyFilterSort

Exit_DanasnjiDatum_Click:
Exit Sub

Err_DanasnjiDatum_Click:
MsgBox Err.Description
Resume Exit_DanasnjiDatum_Click

End Sub

Private Sub DATUM_IZVESTAJA_AfterUpdate()

Me.DATUM_IZVESTAJA.DefaultValue = """" & Me.DATUM_IZVESTAJA.Value & """"

End Sub

Private Sub DEZURNI_DISPECER_AfterUpdate()

Me.DEZURNI_DISPECER.DefaultValue = """" & Me.DEZURNI_DISPECER.Value & """"

End Sub


Private Sub Form_Current()
Requery on Combo1, and Requery on Combo2,
and empti Combo1 and Combo2.
End Sub

Private Sub Form_Load()

DoCmd.GoToRecord , , acLast

End Sub

Private Sub ID_RASKRSNICE_AfterUpdate()
Me.List64.Requery <------------------------------- This has to change by changing the records
Me.List64.Locked = Me.List64.ListCount < 1
Me.List64.Enabled = Me.List64.ListCount > 0
Me.ID_GRESKE.Requery <------------------------------- And this has to change by changing the records
Me.ID_GRESKE.Locked = Me.ID_GRESKE.ListCount < 1
Me.ID_GRESKE.Enabled = Me.ID_GRESKE.ListCount > 0
End Sub

Private Sub Text71_AfterUpdate()

Me.Text71.DefaultValue = """" & Me.Text71.Value & """"

End Sub


Private Sub TrenutnoVreme_1_Click()
On Error GoTo Err_TrenutnoVreme_Click
Me.VREME_KVARA = Time()

DoCmd.RunCommand acCmdApplyFilterSort

Exit_TrenutnoVreme_Click:
Exit Sub

Err_TrenutnoVreme_Click:
MsgBox Err.Description
Resume Exit_TrenutnoVreme_Click

End Sub
Private Sub TrenutnoVreme_2_Click()
On Error GoTo Err_TrenutnoVreme1_Click
Me.VREME_ZATECENOG_STANJA = Time()

DoCmd.RunCommand acCmdApplyFilterSort

Exit_TrenutnoVreme1_Click:
Exit Sub

Err_TrenutnoVreme1_Click:
MsgBox Err.Description
Resume Exit_TrenutnoVreme1_Click

End Sub
Private Sub TrenutnoVreme_3_Click()
On Error GoTo Err_TrenutnoVreme2_Click
Me.VREME_OTKLONJENOG_STANJA = Time()

DoCmd.RunCommand acCmdApplyFilterSort

Exit_TrenutnoVreme2_Click:
Exit Sub

Err_TrenutnoVreme2_Click:
MsgBox Err.Description
Resume Exit_TrenutnoVreme2_Click

End Sub

Private Sub Nazad_Click()
On Error GoTo Err_Command73_Click


DoCmd.GoToRecord , , acPrevious

Exit_Command73_Click:
Exit Sub

Err_Command73_Click:
MsgBox Err.Description
Resume Exit_Command73_Click

End Sub
Private Sub Napred_Click()
On Error GoTo Err_Command74_Click


DoCmd.GoToRecord , , acNext

Exit_Command74_Click:
Exit Sub

Err_Command74_Click:
MsgBox Err.Description
Resume Exit_Command74_Click

End Sub
Private Sub Command75_Click()
On Error GoTo Err_Command75_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command75_Click:
Exit Sub

Err_Command75_Click:
MsgBox Err.Description
Resume Exit_Command75_Click

End Sub
Private Sub Nova_intervencija_Click()
On Error GoTo Err_Command76_Click


DoCmd.GoToRecord , , acNewRec

Exit_Command76_Click:
Exit Sub

Err_Command76_Click:
MsgBox Err.Description
Resume Exit_Command76_Click

End Sub
 
Private Sub Form_Current()
Requery on Combo1, and Requery on Combo2,
and empti Combo1 and Combo2.

Not it, it can be a comment.

put command;

Me.ComboName = ""
Me.ComboName.Requery
 
How can I make 1 combo box fill in the content of another with the same value as that first box but with the possibility of changing if there is a need?
 
combobox2.value = combobox1.value

The .value's are optional (as they are implicit) and the comboboxes will obviously be replaced with your combobox names.

This code will likely be best put in the same place as any code changing the rowsource of the second combobox, assuming that you want to set the value every time that you set the rowsource.
 
Do i put it in a query or in a raw source?
 
How do i do this please help
Cant do it still
 
If you really want to transfer the .value of one to the .value of other then set the code I provided above in the after update VBA event of the first combobox.

Obviously my code uses generic combobox control names which you will need to change to match your control names.
 
Got it - you have to do this
Private Sub combobox1_AfterUpdate()

Me.combobox2.Value = Me.combobox1.Value

End Sub
thanks
 

Users who are viewing this thread

Back
Top Bottom