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

Simple "On Load" question

Status
Not open for further replies.

clickster

MIS
Feb 19, 2002
89
US
I have a form that needs two things to happen. First, it needs to run the following code:

Dim blRet As Boolean
blRet = MouseWheelOFF

I usually do this by simply starting expression builder from the "OnLoad" section of the form's properties sheet. It does the trick.

The second thing I need is for the form to go to a new record "OnLoad". I did this via a simple macro.

The problem is that I need it to do BOTH "OnLoad" and I can't find a way. I can get it to do one or the other just fine, but how do you tell it to first run the code and then go to a new record? I'm sure this is a stupid questions with a simple answer, but I've looked around and can't find one. Any help would be greatly appreciated.
 
set the form's "DataEntry" property to Yes (true)

Or

DoCmd.Goto AcNewRecord

as the last line of your VBA code Or

DoCmd.OpenForm "FormName", , , , AcDataAdd

as the opening statement for the form itself.

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
I think that works. My only problem now is that, when the form open, my Date box has #NAME?, but I have DefaultValue set to Date(). Any ideas why this is? It might help to note that there are 3 tabs on my form. The first one is the main form and the other two are subforms pointing to other tables. I have tried setting GoToRecord>New on just the main form and I have tried setting it on all forms, but the outcome is always the same. How can I get the form to actually open a new record and use the default value in the date field?
 
Instead of setting the default value for the field in question, simply use the onload event to set the date to the current date...

in the onload code add:

Me![datefield] = Date()

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top