Select/Case help needed

L

lcannon1

I have a combo box of database references (cbodatabaserefd). When a nam
is selected, I
need for it to run a query and show the results in another combo bo
(cbonames) to show the names from a particular query that is associate
to the database. I do not really need the query to be open just t
show in the combo box.

This is how I think it would go, I just need some help making it work
Thanks in advance.



If BD is selected from cbodatabaserefd then

docmd.openquery "qrycontactdbaseBD" (and show in cbonames)

If EBP is selected from cbodatabaserefed then

docmd.openquery "qrycontactdbaseEBP" ( and show in cbonames)

If Product is selected from cbodatabaserefd then

docmd.openquery "qrycontactdbaseProduct" (and show in cbonames)

Else cbonnames is empt
 
D

dandgard

If I read this correctly then what you need is a hook to the AfterUpdat
Event of the cbodatabaserefd combo box control which would run a even
procedure with a select statement like below

Select Case cbodatabaserefd
Case "BD"
run query
set value
Case "EBP"
run query
set value
Case "......
 
D

dandgard

If I read this correctly then what you need is a hook to the AfterUpdat
Event of the cbodatabaserefd combo box control which would run a even
procedure with a select statement like below

Select Case cbodatabaserefd
Case "BD"
run query
set value
Case "EBP"
run query
set value
Case "......
 
L

lcannon1

Yes, and I have that now. I need to know though I have this code in th
same After_update Event. Do I place the Select Case code after the En
If of this code????

Private Sub cboDatabaseRefd_AfterUpdate()
If [cboDatabaseRefd] = "EBP" Then
cboContactName.RowSource = "select [name] from qryEBP_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "Sales Logix" Then
cboContactName.RowSource = "select [name] fro
qrySalesLogix_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "BD" Then
Me.frmAddContact_Subform.Form.AllowAdditions = True
Me.frmAddContact_Subform.Form.AllowDeletions = True
Me.frmAddContact_Subform.Form.AllowEdits = True
cboContactName.RowSource = ""
cboContactName.Requery

End If
End Su
 
L

lcannon1

Yes, and I have that now. I need to know though I have this code in th
same After_update Event. Do I place the Select Case code after the En
If of this code????

Private Sub cboDatabaseRefd_AfterUpdate()
If [cboDatabaseRefd] = "EBP" Then
cboContactName.RowSource = "select [name] from qryEBP_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "Sales Logix" Then
cboContactName.RowSource = "select [name] fro
qrySalesLogix_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "BD" Then
Me.frmAddContact_Subform.Form.AllowAdditions = True
Me.frmAddContact_Subform.Form.AllowDeletions = True
Me.frmAddContact_Subform.Form.AllowEdits = True
cboContactName.RowSource = ""
cboContactName.Requery

End If
End Su
 
L

lcannon1

Yes, and I have that now. I need to know though I have this code in th
same After_update Event. Do I place the Select Case code after the En
If of this code????

Private Sub cboDatabaseRefd_AfterUpdate()
If [cboDatabaseRefd] = "EBP" Then
cboContactName.RowSource = "select [name] from qryEBP_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "Sales Logix" Then
cboContactName.RowSource = "select [name] fro
qrySalesLogix_contacts"
Me.frmAddContact_Subform.Form.AllowAdditions = False
Me.frmAddContact_Subform.Form.AllowDeletions = False
Me.frmAddContact_Subform.Form.AllowEdits = False
ElseIf [cboDatabaseRefd] = "BD" Then
Me.frmAddContact_Subform.Form.AllowAdditions = True
Me.frmAddContact_Subform.Form.AllowDeletions = True
Me.frmAddContact_Subform.Form.AllowEdits = True
cboContactName.RowSource = ""
cboContactName.Requery

End If
End Su
 
D

dandgard

I don't understand??? You have already effectively created a Cas
statement with the if..Elseif statements in your code. Why do you nee
the Select statement
 
D

dandgard

I don't understand??? You have already effectively created a Cas
statement with the if..Elseif statements in your code. Why do you nee
the Select statement
 
D

dandgard

I don't understand??? You have already effectively created a Cas
statement with the if..Elseif statements in your code. Why do you nee
the Select statement
 
L

lcannon1

This is another code different than the select statement that I used
Two seperate events. :
 
L

lcannon1

This is another code different than the select statement that I used
Two seperate events. :
 
L

lcannon1

This is another code different than the select statement that I used
Two seperate events. :
 

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