Show Data from ComboBox (1 Viewer)

JuniorWoodchuck24

Registered User.
Local time
Today, 02:33
Joined
Jan 13, 2010
Messages
59
My problem is occuring due to the following:
I have a form that the user inputs information into and clicks a button to save this data to a table. Then the user goes into another form that on load pulls some of the table information.

The initial form value entered is based on a combo box, and it pulls in ID / LineSize. This is written to the table and the table's field value it set as Number: combobox so it shows the LineSize. 2 column count, 0";2"

My error is when I load it into the second form it pulls the ID number into the text box. Is there a way to pull the LineSize in? To Load I'm using the following:

Dim db As Database
Dim rs As Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("tbl1", dbOpenDynaset)

Me.txtLinSize = rs!LineSize

I know that in certain instances to pull certain data from a combo box you do the cboLineSize.Column(1), but how would this syntax be used when pulling it off a table?
 

JuniorWoodchuck24

Registered User.
Local time
Today, 02:33
Joined
Jan 13, 2010
Messages
59
I might have been a bit confusing in my earlier post so I'll go into more detail.

1st Form

cboLineSize (combo box that pulls from a table with line sizes, when it pulls information it gets ID / Line Size)

tbl1

LineSize (Field) - Receives information from 1st Form
properties: Number - 2 columns - column width 0";2" (this hides ID / shows Line Size)

2nd Form

txtLineSize (want this to receive the Line Size not the ID)

I can make it pull the value if it's a combo box, but trying to see if I can pull in the Line Size value not the ID in a text box. Some times when you're requiring specific information from a combo box you add the .Column(x) to the end. This syntax cannot be used with the current method of loading I'm using. If I'm uncapable of using a textbox I'll just go back to using a combo box which I don't mind. Just seeing if I can get away with using a text box. And yes sir, using a Query can pull the info in if I use combo box and its RowSource.
 

vbaInet

AWF VIP
Local time
Today, 08:33
Joined
Jan 22, 2010
Messages
26,374
Actually I understood what you wrote in your first post that was why I suggested those two methods. If you don't want to "Create a query to include that field and use the query as the Record Source of your form" then just use the DLOOKUP function. It can pull information from anywhere and you can use a dlookup in the Record Source of a textbox.

Post back if you're finding it difficult to string together the DLOOKUP syntax.
 

JuniorWoodchuck24

Registered User.
Local time
Today, 02:33
Joined
Jan 13, 2010
Messages
59
I got it working used:

Me.txtLineSize = DLookup("Sizes", "tblLineSize", "ID=" & rs!LineSize)

Totally forgot that I could compare the "ID" number I currently pulled from the original storage table. Thanks for the help and apologies for my mental block.
 

vbaInet

AWF VIP
Local time
Today, 08:33
Joined
Jan 22, 2010
Messages
26,374
Using a recordset (to load data into a form) with the DLOOKUP is actually not necessary. Why don't you base your second form on a query or on the tbl1 table instead?
 

Users who are viewing this thread

Top Bottom