If not null then go to new record

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

Guest

I am trying to make it so when a form opens if the last record is not null
then it goes directly to a new record.

I have tried to create various macros and can't get it to work.

Please help.
 
miamoe said:
I am trying to make it so when a form opens if the last record is not
null then it goes directly to a new record.

I have tried to create various macros and can't get it to work.

Please help.

What do you mean by "if the last record is not null"? Records can't be
Null, so all I can think of is that either you want to know whether a
particular field is Null, or whether there are any records at all.
 
miamoe said:
ya sorry, it is if a particular field is empty. Thanks

Would the form be displaying at most one record? Would the code need to
check this on just the first record -- the one that become current when
the form is first opened -- or on all the records on the form?
 
the one that become current when the form is first opened -- since I have the
form set to gotolast when it opens.
 
miamoe said:
the one that become current when the form is first opened -- since I
have the form set to gotolast when it opens.

I'm still not sure what you actually have implemented, but maybe what
you have in mind is this: when the form is opened, it should go to the
last record. But if, in that record, some field is not Null, then it
should go to a new record instead.

If that's the behavior you want, then this event procedure for the
form's Load event will probably do it:

'----- start of example code -----
Private Sub Form_Load()

RunCommand acCmdRecordsGoToLast

If Not IsNull(Me.YourFieldName) Then
RunCommand acCmdRecordsGoToNew
End If

End Sub
'----- end of example code -----

You must replace "YourFieldName" with the name of the field that you
want to check for Null.

That may not be what you had in mind, but it's my best guess from what
you've said so far.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top