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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continuous Forms: How do I disable a button until... 1

Status
Not open for further replies.

jasonmac

Programmer
Nov 14, 2002
175
US
Hello everyone. I'm using Access '97 and I have a question about one of my subforms. The subform is a continuous form that has a command button. When the command button is clicked it opens a new form that is dependent on an AutoNumber field in my subform. So here's the problem. If I click that button before I enter anything on the newest line of the form (the new record)I get an error because that field happens is Null. Can anyone help me get around this?

Thanks in advance,
Jason
 
on the onclick event :

if autonumberfield <> Null then
docmd.openform myform
else
msgbox "Error :..."

 
Thought ---

If there are other fields left blank, but you don't want to go to the new form unless all or certain ones are filled in, try in the On Click of the button something like:

If [FieldA] or [FieldB] or .... Is Null then
'you could also use the and operator
msgbox" You need to fill in...."

You could also use the vb yes/no to confirm and if what you want eneterd lacks, use Undo to return to the record.

Your exact coding will be more comprehensive, this is a concept.

Good Luck!

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description thread 702-5106
 
I've tried both of those solutions. But the if statement's don't work. I think it may be because it record you are looking at isn't technically a record yet. I'm talking about when the AutoNumber field still says "AutoNumber" in the text box. It seems like only when something is entered into one of the other text boxes does it become a record and the autonumber field is populated.
 
Works like a charm Randy. Thanks to everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top