Forms help

G

Guest

I need help in having a form call data from a form it is not connected to.

Brief Background:
I have a number of tables in my project, and I have a formed that is
attached to a master table. On that form, I was able to get a combobox to
display data from one of the external tables (A list of vehicles, aptly named
'vehicles'). The box is showing the vehicle ID #s. And next to this box,
there is another box, that I would like to display the vehicle's respective
capacity (which is stored in the vehicles table, with each ID number).

So to attempt this, I set the After Update on the vehicle field on the form
to:

Private Sub Equipment_AfterUpdate()
DIM sSQL As String

sSQL = "SELECT vehicleID, capacity " _
& " FROM vehicles WHERE number = " & Me.Equipment

Me.Yards.RowSource = sSQL
Me.Yards.Requery

End Sub

THAT'S IT.
So no luck so far, nothing comes up in the second box. And i've tried with
and without the RowSource text, and as both a combobox and a text box.
Anyway, any help would be greatly appreciated.
 
A

Arvin Meyer

Try this to display the value on the form in the Yards textbox:

Private Sub Equipment_AfterUpdate()

Me.Yards = Me.Equipment.Column(1)

End Sub

Column(n) is the index number of the columns in your rowsource, starting at
0. So if there are 2 columns (no matter how many are displayed) their
indices are 0 and 1.

HTH
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
G

Guest

Worked perfectly! Thanks so much Arvin.

Arvin Meyer said:
Try this to display the value on the form in the Yards textbox:

Private Sub Equipment_AfterUpdate()

Me.Yards = Me.Equipment.Column(1)

End Sub

Column(n) is the index number of the columns in your rowsource, starting at
0. So if there are 2 columns (no matter how many are displayed) their
indices are 0 and 1.

HTH
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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

Similar Threads


Top