BeforeUpdate - Setting Values

J

Jorge Ramos

Hello all,

I created the following sub to set values on three different fields from a
data entry form. The sub works well but only for the first line, which
assigns the current date and time to the [DatabaseTimestamp] field. The
other two does not seem to work. Would you let me know what is wrong with
the following code?:

Private Sub Form_BeforeUpdate(Cancel As Integer)


DatabaseTimestamp = Now()

FirstOrSecond = 2

UserNameIs = fOSUserName()


BeforeUpdate_End:

Exit Sub


End Sub



If it helps, Im running Access 2003 on Win XP



Thank you!!
 
R

ruralguy via AccessMonster.com

Are all three objects controls on your form?
Me.DatabaseTimestamp = Now()
Me.FirstOrSecond = 2
Me.UserNameIs = fOSUserName()

...or are the last two just fields in the RecordSource>
Me.DatabaseTimestamp = Now()
[FirstOrSecond] = 2
[UserNameIs] = fOSUserName()


Jorge said:
Hello all,

I created the following sub to set values on three different fields from a
data entry form. The sub works well but only for the first line, which
assigns the current date and time to the [DatabaseTimestamp] field. The
other two does not seem to work. Would you let me know what is wrong with
the following code?:

Private Sub Form_BeforeUpdate(Cancel As Integer)

DatabaseTimestamp = Now()

FirstOrSecond = 2

UserNameIs = fOSUserName()

BeforeUpdate_End:

Exit Sub

End Sub

If it helps, Im running Access 2003 on Win XP

Thank you!!
 
J

Jorge Ramos

RG,

Thank you! The last two fields are in the RecordSource. I bracketed [ ] the
fields as you indicated and it works great.

I appreciate your help!

Jorge


ruralguy via AccessMonster.com said:
Are all three objects controls on your form?
Me.DatabaseTimestamp = Now()
Me.FirstOrSecond = 2
Me.UserNameIs = fOSUserName()

..or are the last two just fields in the RecordSource>
Me.DatabaseTimestamp = Now()
[FirstOrSecond] = 2
[UserNameIs] = fOSUserName()


Jorge said:
Hello all,

I created the following sub to set values on three different fields from a
data entry form. The sub works well but only for the first line, which
assigns the current date and time to the [DatabaseTimestamp] field. The
other two does not seem to work. Would you let me know what is wrong with
the following code?:

Private Sub Form_BeforeUpdate(Cancel As Integer)

DatabaseTimestamp = Now()

FirstOrSecond = 2

UserNameIs = fOSUserName()

BeforeUpdate_End:

Exit Sub

End Sub

If it helps, Im running Access 2003 on Win XP

Thank you!!
 
R

ruralguy via AccessMonster.com

Glad I could help Jorge.

Jorge said:
RG,

Thank you! The last two fields are in the RecordSource. I bracketed [ ] the
fields as you indicated and it works great.

I appreciate your help!

Jorge
Are all three objects controls on your form?
Me.DatabaseTimestamp = Now()
[quoted text clipped - 31 lines]
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 

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

Similar Threads


Top