textbox Default value from query

Badvoc

Registered User.
Local time
Today, 15:38
Joined
Apr 22, 2009
Messages
69
I am trying to do something I first thought would be simple, Doh!
I want to open a form to add a new record to a table, (Done that)
When the form opens I want certain fields already filled in with data from a query.
What I have is:
Table with Name, logonID & dept
Query that returns the Name & Dept from the table using the logonID as criteria : fOSUserName()
Form with 2 textboxes with there default value is set to the Name and Dept from the query.

The query works fine.
The form however is proving a bit troublesome as the textboxes only display #Name?

What am I doing wrong?
 
From what you have described it could be down to naming conventions. If you have a field name called "Name" this is a reserved word in Access, therefore conflicts are arising. Try renaming your fields or at least wrap them in [] to declare them as fields.

David
 
Thanks
although the field was EmployeeName took name off the end in all forms and query and now it works.
great one
 
Why not do this in code rather than trying to set default values?

Call the UserName func
Query the user table
get the data from the rs
set the controls from the above data

This will also allow you to do some err checking etc
(If user does note exist in table then close the form)
 

Users who are viewing this thread

Back
Top Bottom