Setting a Default Value

savix

Registered User.
Local time
Today, 13:35
Joined
Jun 17, 2005
Messages
10
Hi,
I'm trying to set a default value to field in a form. The field relates to Table 1 and I need a value from Table 2 as Default!
I've tried entering an SQL query:
Select Max(ID) From.... ;
But it doesn't work! Maybe It's just a question of syntax??
Thanx for your help.
 
Try Nz(DMax("ID","tblTable2"),<value to use if no records found on table2>)

Dave
 
Thanks!!
Actually it doesn't work, Access says that there's a sytax error. I entered it in the properties of the object...
 
yes, here's one option I tried:

=Nz(DMax(ID,Meeting),0)
 
You need quotes around the field and table name (see my original post!):

Nz(DMax("ID","Meeting"),0)

ID and Meeting are just strings, not variable names - VBA doesn't know what they are.

Dave
 
Sorry, I forgit to put the quotes in my last message.
I tried it with quotes, still the same syntax error box from access
 
Don't get this - I've just tried it myself to make sure I haven't forgotten anything and it works fine. Let me check:

You have a form with a text box, and in the Default Value field under properties you have

=Nz(DMax("ID","Meeting"),0)

and you're getting a syntax error?

You do actually have a table called Meeting with a field called ID on it?

Dave
 
It's strange, but I've solved the problem by adding the code behind (associated with an event), which works well.
Thanks for your help


Sav
 

Users who are viewing this thread

Back
Top Bottom