Select/Case help needed

  • Thread starter Thread starter lcannon1
  • Start date Start date
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
 
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 "......
 
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 "......
 
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
 
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
 
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
 
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
 
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
 
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
 
This is another code different than the select statement that I used
Two seperate events. :
 
This is another code different than the select statement that I used
Two seperate events. :
 
This is another code different than the select statement that I used
Two seperate events. :
 
Back
Top