record source

G

Guest

Hi all,
I have a form called "credentials",on this form there's a button called
"Change",this button changes the record source form "active table" to "Not
activetable",

The problerm is that i have a combo box on this form that looks for the
value of "agent name" from the "active table" ,how can i ,by clicking the
button "change",change the record source of this combo box to make it look
for the value "agent name" but from the "Not activetable".in other words to
allow this combo box to have its row source from the same table of the form.

Another problem, I have another combo box called "Team" that's supposed
to look for the value of "team" form the "activetable" ,it has the following
settings:
Row source type: Table/Query
Row source : activetable
Bound columns : 1
But it displays the value of "agent name" as it's the first field of the
table,how can i make it display the value "team".

Regards
 
G

Guest

For the first combo box set its RowSource property and requery the control in
the button's Click event procedure as well as changing the form's
RecordSource property, e.g. to toggle between the two RecordSource and
RowSource properties:

Dim strRecordSource as String

strRecordSource = Me.RecordSource

If strRecordSource = "ActiveTable" Then
strRecordSource = "NotActiveTable"
Else
strRecordSource = "ActiveTable"
End If

Me.RecordSource = strRecordSource
Me.cboAgent.RowSource = "SELECT AgentName FROM " & _
strRecordSource & " ORDER BY AgentName"
Me.cboAgent.Requery

For the Team combo box don't use a table name as its RowSource. Use an SQL
SELECT statement which returns the column from the table:

SELECT Team FROM ActiveTable ORDER BY Team;

Remember hat if a table or field name includes spaces or other special
characters you have to wrap the name in square brackets [like this]. I'd
recommend avoiding spaces; if you want a space in an object name use an
underscore character like_this. Similarly avoid special characters; instead
of Invoice# for example use InvoiceNumber as the column name.

Ken Sheridan
Stafford, England
 

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