Various Control Sources

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good afternoon,
I have a basic form that has some field locks. One of the locked text boxes needs to pull in Division from my query (Query1). The query gets the user's division by performing a select query with the criteria of Requestor Name = CurrentUser(). So, the field I want to populate my text box should be [Query1].[Division], I would think. Whenever I build the expression and run the form, I get #Name?.

Can someone help me out? I'm in 2000 on a Windows 2000 machine.

Thanks!
Derek
 
Hi,
If you want to populate a control on a form with info that is not in
the query or table that the form is bound to, try using DLookup.
You cannot reference a query the way you're trying.

--
HTH
Dan Artuso, Access MVP


Derek Wittman said:
Good afternoon,
I have a basic form that has some field locks. One of the locked text boxes needs to pull in Division from my query (Query1).
The query gets the user's division by performing a select query with the criteria of Requestor Name = CurrentUser(). So, the field
I want to populate my text box should be [Query1].[Division], I would think. Whenever I build the expression and run the form, I
get #Name?.
 
Derek,

Is Query1 part of the form's recordsource? If it is, you should just
be able to bind the textbox directly to the Division field from the
query. If not, can you include Query1 in the form's recordsource? If
not, one way to reference it in the form would be to use this in the
textbox's controlsource...
=DLookup("[Division]","Query1")

- Steve Schapel, Microsoft Access MVP
 
Dan and Steve, thanks for the help. The DLookup was the exact answer I was looking for. My next little 'project' is to make it so if I am the CurrentUser(), I can type in the Division. Any other users, I want it locked so they can't change it. I'll look into making it happen and will post if I need the help. (I try to be self-taught as much as possible, but certainly appreciate the experts' help!)

Derek

----- Steve Schapel wrote: -----

Derek,

Is Query1 part of the form's recordsource? If it is, you should just
be able to bind the textbox directly to the Division field from the
query. If not, can you include Query1 in the form's recordsource? If
not, one way to reference it in the form would be to use this in the
textbox's controlsource...
=DLookup("[Division]","Query1")

- Steve Schapel, Microsoft Access MVP


Good afternoon,
I have a basic form that has some field locks. One of the locked text boxes needs to pull in Division from my query (Query1). The query gets the user's division by performing a select query with the criteria of Requestor Name = CurrentUser(). So, the field I want to populate my text box should be [Query1].[Division], I would think. Whenever I build the expression and run the form, I get #Name?.
Can someone help me out? I'm in 2000 on a Windows 2000 machine.
Thanks!
Derek
 
I've 'band-aided' my own solution. Instead of a true LOCK to the textboxes, I've made them appear locked by transparent background, defaulting to the DLookup, a FLAT Special Effect, and a transparent border. Of course, if someone clicks on the value to change it, then, if I understand, it will probably change the value in the table that's behind Query1... is this right?

The nice thing is, if it doesn't change the table, but the user changes the Division value, I know which division it is by the CurrentUser() on the form.

Thanks!
Derek

----- Derek Wittman wrote: -----

Dan and Steve, thanks for the help. The DLookup was the exact answer I was looking for. My next little 'project' is to make it so if I am the CurrentUser(), I can type in the Division. Any other users, I want it locked so they can't change it. I'll look into making it happen and will post if I need the help. (I try to be self-taught as much as possible, but certainly appreciate the experts' help!)

Derek

----- Steve Schapel wrote: -----

Derek,

Is Query1 part of the form's recordsource? If it is, you should just
be able to bind the textbox directly to the Division field from the
query. If not, can you include Query1 in the form's recordsource? If
not, one way to reference it in the form would be to use this in the
textbox's controlsource...
=DLookup("[Division]","Query1")

- Steve Schapel, Microsoft Access MVP


Good afternoon,
I have a basic form that has some field locks. One of the locked text boxes needs to pull in Division from my query (Query1). The query gets the user's division by performing a select query with the criteria of Requestor Name = CurrentUser(). So, the field I want to populate my text box should be [Query1].[Division], I would think. Whenever I build the expression and run the form, I get #Name?.
Can someone help me out? I'm in 2000 on a Windows 2000 machine.
Thanks!
Derek
 
Back
Top