Combo Value Depending On Other Combo Value

D

Daniel

Hello All,

I have a table (table1) that has field names(columns) such as

Request for Payment (field name) with data under each like...
Incorrect Control Number(data)
Incorrect Date Range(data)

Notice of Concern(field name)
Incorrect Contractor(data)
Need Notice(data)

I have a form that has two combo boxes on it. Depending which Field List
name is select from combo1 it is supposed to select the corrosponding data
under that field name and allow it to be selected from combo2. I am using
the following code:

Dim strSQL As String
strSQL = "Select " & "'" & Me!combo1 & "'"
strSQL = strSQL & " from table1"
Me!combo2.RowSourceType = "Table/Query"
Me!combo2.RowSource = strSQL

When I try to click on the dropdown, I get the following message:

The record source 'Select 'Request for Payment' from table1' specified on
this form or report does not exist. You misspelled the name, or it was
deleted or renamed in the current database, or it exists in a different
database.

Can anyone tell me what I am doing wrong, because I have used this same code
in another database and it works fine.

Thanks
 
G

Gerald Stanley

The columnName should be enclosed in [] not ' '.
Try
Dim strSQL As String
strSQL = "Select " & "[" & Me!combo1 & "]"
strSQL = strSQL & " from table1"
Me!combo2.RowSourceType = "Table/Query"
Me!combo2.RowSource = strSQL

Hope That Helps

Gerald Stanley MCSD
 
D

Daniel

Thank You Gerald

I knew there was some stupid little thing like that I was missing. It
worked!

Daniel



Gerald Stanley said:
The columnName should be enclosed in [] not ' '.
Try
Dim strSQL As String
strSQL = "Select " & "[" & Me!combo1 & "]"
strSQL = strSQL & " from table1"
Me!combo2.RowSourceType = "Table/Query"
Me!combo2.RowSource = strSQL

Hope That Helps

Gerald Stanley MCSD
-----Original Message-----
Hello All,

I have a table (table1) that has field names(columns) such as

Request for Payment (field name) with data under each like...
Incorrect Control Number(data)
Incorrect Date Range(data)

Notice of Concern(field name)
Incorrect Contractor(data)
Need Notice(data)

I have a form that has two combo boxes on it. Depending which Field List
name is select from combo1 it is supposed to select the corrosponding data
under that field name and allow it to be selected from combo2. I am using
the following code:

Dim strSQL As String
strSQL = "Select " & "'" & Me!combo1 & "'"
strSQL = strSQL & " from table1"
Me!combo2.RowSourceType = "Table/Query"
Me!combo2.RowSource = strSQL

When I try to click on the dropdown, I get the following message:

The record source 'Select 'Request for Payment' from table1' specified on
this form or report does not exist. You misspelled the name, or it was
deleted or renamed in the current database, or it exists in a different
database.

Can anyone tell me what I am doing wrong, because I have used this same code
in another database and it works fine.

Thanks


.
 

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