Need help with code and query

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I am trying to dynamically populate three dropdowns. The
first 2 dropdowns work fine.

Here is the 2nd query I am using for the 2nd dropdown.
This will select the divisions for the company.
SELECT [company].[division]
FROM company
WHERE ((([company].[custID])=[Forms]![frmlinkedcomboboxes]!
[cboCust]));

This is what I have for selecting the jobsites in that
division for that company.

SELECT company.Jobsite
FROM company
WHERE (((company.Jobsite)=[Forms]![frmlinkedcomboboxes]!
[cboJobsite]));


Here is my code for my comboboxes, etc

Option Compare Database

Private Sub cboCust_AfterUpdate()

Dim strSearch As String
Dim strSearch1 As String

'For text IDs
strSearch = "[CustID] = " & Chr$(34) & Me![cboCust] &
Chr$(34)
strSearch1 = "[CustID] = " & Chr$(34) & Me!
[cboJobsite] & Chr$(34)
'Find the record that matches the control.
Me.RecordsetClone.FindFirst strSearch
Me.RecordsetClone.FindFirst strSearch1
Me.Bookmark = Me.RecordsetClone.Bookmark

'requery the boat combox box so that it shows correct
information (given in the row source)
Me![cboDivision].Requery
Me.cboDivision.Enabled = True
Me![cboDivision].Value = "Select Division"

Me![cboJobsite].Requery
Me.cboJobsite.Enabled = True
Me![cboJobsite].Value = "Select Jobsite"


End Sub

Private Sub Form_Load()
Me.cboCust.Value = "select a customer"
Me.cboDivision.Enabled = False
Me.cboJobsite.Enabled = False


End Sub


My third dropdown will not populate with the jobsites.
Please help if you can.

Thanks,
Greg
 
Check the SQL String for the cboJobSite. You refer to its
value in the SQL String. I would expect the SQL String to
be something like:

SELECT company.Jobsite
FROM company
WHERE (((company.*Division*)=[Forms]![frmlinkedcomboboxes]!
[cbo*Division*]));

HTH
Van T. Dinh
MVP (Access)
 
Back
Top