471,355 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

Refering to a value in a field in a different table/query from a form

Hi Access boffins,

I've a form that I want to give users the option of choosing whether
certain fields are visible or not. So I've created a table mirroring
the original table called tblVisibleFields, and a form with loads of
checkboxes on it. Then, in the main form, I've put the following code:

Private Sub Form_Activate()

If Tables!tblVisibleFields!ProjectNumber = True Then
Me.ProjectNumber = Visible
End If

End Sub

However, it comes up with an 'Object required' error message. Any
ideas how I can get around this? I tried redoing it with a query
based on the table. I'm thinking it's something to do with access
wanting a value, rather than just a field. Do I need to use DLookup
or something? Any help much appreciated.

Jan 28 '07 #1
1 1309
"adampope" <po******@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
Hi Access boffins,

I've a form that I want to give users the option of choosing whether
certain fields are visible or not. So I've created a table mirroring
the original table called tblVisibleFields, and a form with loads of
checkboxes on it. Then, in the main form, I've put the following code:

Private Sub Form_Activate()

If Tables!tblVisibleFields!ProjectNumber = True
[snip]

You cannot pull a value from a table with that syntax. When a table has
multiple rows which row would that syntax be looking at?

Check help for the DLookup() function. It does exactly what you are looking
for.

A somewhat more efficient method would be to create a Recordset object in your
code because that would retrieve all the fields at one time and you could grab
each value with one fetch.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Jan 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by David B | last post: by
3 posts views Thread by William Wisnieski | last post: by
3 posts views Thread by Annette Massie | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.