Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rowsource for Lookup in VBA?

Status
Not open for further replies.

Keph

Technical User
Oct 15, 2002
16
0
0
CA
Hi, when in the design view of a table, there is a tab at the bottom that says 'Lookup'. In this tab there are two settings 'Rowsource' and 'RowsourceType'. I would like to be able to set these using VBA. CurrentDB.TableDefs("MyTable").Fields("MyField") does not seem to have a rowsource or rowsource property. Am I missing something or is there another/better way of doing this?

Thanks,
Keph
 
Did you receive any feedback from this question? I'm trying to do the same thing, with the same problem.
 
Row Source Type and RowSource are properties of listboxes and coombo boxes - not fields.

rollie@bwsys.net
 
I understand that they aren't properties of fields - that's why I'm asking for help. Doesn't anyone know how to do this? :(
 
Keph,

Let me first say I don't know how to do what you are asking.

Now, let me say that you really probably don't want to do it anyway. In the long run, you are only going to encounter problem with this setup. This has been discussed many times here at Tek-Tips...i would suggest looking back at some old thread on table lookups and the like.

Long story short, the problem will lie in the fact that your field will show one thing but be truly storing a different value in most cases. This may not be a problem for you now, but later on, when you go to change something, or code something, you will find the differences in the display and the stored data to cause you serious headache.

I am not trying to deter you from what you are trying to do...I just want to help you out....It sounds to me like you have two table...that are linked in a one to many relatiosnhip (as you see it). Each table should store the VALUES...then use queries and lookups on the forms and reports to display the correct values to your users. As a side-note, this is important because USERS should NEVER and even the programmer should RARELY ever even see the tbale....so why set a lokoup at the table level????

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: wildmage@tampabay.rr.com
 
mstrmage1768, thank you for your advice! I can see the logic in what your saying. However, I'll have to think about this a bit more, because for my project (which is relatively small and simple with only a few users) I think it might be simplest to leave the lookup at the table level. Either way, thanks for your feedback.

Keph
 
I've looked into this a bit more. I really need to be able to view many rows of data all at once and have that view editable. A table view is perfect for this except that I can't figure out how to program a lookup in a field using VBA. The lookup is important as well, since it's difficult to remember what '342', '22' or '586' are liked to in some other table.

I've found that there is a lookup tab in the design view of queries as well but have similar problem with setting it programatically.

Can anyone suggest a solution?

Keph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top