Statement separator for multiple DLast statements – Access 2003

45 pts.
Tags:
Microsoft Access
Microsoft Access 2003
MS Access

I am trying to set defaults for selected fields in a form based on the previous (last) record.

I can do this for a single field using the code below in Form Properties/BeforeInsert but I need to add three more fields. Is this possible and, if so, how should I phrase it and what separator should I use between each statement? Private Sub Form_BeforeInsert(Cancel As Integer) Room = DLast("Room", Me.RecordSource) End Sub Thank you.

Software/Hardware used:
MS Access 2003

Answer Wiki

Thanks. We'll let you know when a new response is added.

You just need to put each instruction in a new line:

<pre>Private Sub Form_BeforeInsert(Cancel As Integer)
Room = DLast(“Room”, Me.RecordSource)
Name = DLast(“Name”, Me.RecordSource)
OtherField = DLast(“OtherField”, Me.RecordSource)
End Sub</pre>

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TRSJ
    Carlos, Thank you for this. It works for fine some fields (after I worked out how to refer to field names that have several words!) but not others, specifically fields that have drop-down boxes to select from. Any suggestions? Best wishes.
    45 pointsBadges:
    report
  • carlosdl
    I think it should work with combo boxes also, but they must be bound to some table column.
    69,510 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following