New record Event

  • Thread starter Thread starter Syd
  • Start date Start date
S

Syd

I have two (cboDropdown1 and cboDropdown2) drop down
controls. One sets to the first of two parameters the
second drop down sets the other parameter to complete a
record. Whenever that form comes up it is set to come in
new record mode. What I'd like to accomplish, is if the
second control's parameter has not yet been set to have to
the form come up to record that is not yet completed with
the form showing the second parameter to be set.

Any ideas will be appreciated....

Thanks,
 
I assume by your description that the 2 combo boxes are on the form that is
being opened. Also, that the reason the form goes to a new record is because
its DataEntry property is set to yes.

Yes, it is possible to go to the first record that has an empty field for
one of the 2 combo boxes. However, what do you want to do if there is more
than one record like this? What if both have a Null Value? It may be better
to prevent this from happening in the first place by using the Form's
BeforeUpdate event to make sure all required fields are filled in before the
record is saved.

To find the first record with a Null value, try the following in the Form's
OnLoad event:

I am using Field1 as the field that Combo 1 is using as its BoundField and
Field2 as the field that Combo 2 is using as its BoundField.

If DCount("*", Me.RecordSource, "[Field1] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field1] Is Null"
ElseIf DCount("*", Me.RecordSource, "[Field2] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field2] Is Null"
End If
 
Wayne:

Yes, there are more many records in the table-query behind
the form. However, I wish to have the form open to last
record with an empty control only if the the record is not
complete. Be complete I mean that both required controls
are populated. If that is the case, then, open to a new
record, if both control are not populated (i.e: the second
control)is "" or null, then, open to the last record to
allow the second control to be populated to make that
record complete. Otherwise, go to acNewRec.

Hope this helps...

-----Original Message-----
I assume by your description that the 2 combo boxes are on the form that is
being opened. Also, that the reason the form goes to a new record is because
its DataEntry property is set to yes.

Yes, it is possible to go to the first record that has an empty field for
one of the 2 combo boxes. However, what do you want to do if there is more
than one record like this? What if both have a Null Value? It may be better
to prevent this from happening in the first place by using the Form's
BeforeUpdate event to make sure all required fields are filled in before the
record is saved.

To find the first record with a Null value, try the following in the Form's
OnLoad event:

I am using Field1 as the field that Combo 1 is using as its BoundField and
Field2 as the field that Combo 2 is using as its BoundField.

If DCount("*", Me.RecordSource, "[Field1] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field1] Is Null"
ElseIf DCount("*", Me.RecordSource, "[Field2] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field2] Is Null"
End If


--
Wayne Morgan
Microsoft Access MVP


Syd said:
I have two (cboDropdown1 and cboDropdown2) drop down
controls. One sets to the first of two parameters the
second drop down sets the other parameter to complete a
record. Whenever that form comes up it is set to come in
new record mode. What I'd like to accomplish, is if the
second control's parameter has not yet been set to have to
the form come up to record that is not yet completed with
the form showing the second parameter to be set.

Any ideas will be appreciated....

Thanks,


.
 
Wayne:

Yes, there are more many records in the table-query behind
the form. However, I wish to have the form open to last
record with an empty control only if the the record is not
complete. Be complete I mean that both required controls
are populated. If that is the case, then, open to a new
record, if both control are not populated (i.e: the second
control)is "" or null, then, open to the last record to
allow the second control to be populated to make that
record complete. Otherwise, go to acNewRec.

Hope this helps...

-----Original Message-----
I assume by your description that the 2 combo boxes are on the form that is
being opened. Also, that the reason the form goes to a new record is because
its DataEntry property is set to yes.

Yes, it is possible to go to the first record that has an empty field for
one of the 2 combo boxes. However, what do you want to do if there is more
than one record like this? What if both have a Null Value? It may be better
to prevent this from happening in the first place by using the Form's
BeforeUpdate event to make sure all required fields are filled in before the
record is saved.

To find the first record with a Null value, try the following in the Form's
OnLoad event:

I am using Field1 as the field that Combo 1 is using as its BoundField and
Field2 as the field that Combo 2 is using as its BoundField.

If DCount("*", Me.RecordSource, "[Field1] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field1] Is Null"
ElseIf DCount("*", Me.RecordSource, "[Field2] Is Null") Then
Me.DataEntry = False
Me.Recordset.FindFirst "[Field2] Is Null"
End If


--
Wayne Morgan
Microsoft Access MVP


Syd said:
I have two (cboDropdown1 and cboDropdown2) drop down
controls. One sets to the first of two parameters the
second drop down sets the other parameter to complete a
record. Whenever that form comes up it is set to come in
new record mode. What I'd like to accomplish, is if the
second control's parameter has not yet been set to have to
the form come up to record that is not yet completed with
the form showing the second parameter to be set.

Any ideas will be appreciated....

Thanks,


.
 
I understand generally what you are after. The question wasn't whether there were more
records, the question was what to do if there is more than one incomplete record.

I take it you want to just go to the last one and not worry about the others. To do that,
you have to do something to define the "last" one, such as including a date/time stamp
field so that you know which record was added last. The code in the previous message will
show you how to detect the empty fields, it will need to be modified slightly to find the
last one. You would use FindFirst or FindLast on the date/time field on a recordset sorted
by the date/time field with criteria that the combo box's bound field Is Null. Whether you
search for the first or last will depend on whether you sort the date/time field ascending
or descending. Records in the table are not necessarily in the order in which you enter
them and if they are currently, there is no guarantee that they will stay that way.
 
Back
Top