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

set fields to NULL after button click

Status
Not open for further replies.

load3d

Programmer
Feb 27, 2008
117
US
Question 1/2: I want to set the fields in my to null after I click my save button. Currently I close the form and reopen it again but I want to get away from that.

NOTE: This field is in a subform

Question two:

I originally did a close form and then open form because I wanted my time stamp to be refreshed. How can I refresh my time stamp at the same time as setting fields to NULL?



Main form name: Newdesign
Subform control name: Frame
Subform name: Appointment

 
dim frm as form
set frm = forms("Newdesign").Frame.form

frm.undo
frm.timstampfield=now()

 
How are ya Mbarbine . . .

If you want a new time stamp per record, it would be (assuming your save button is on the mainform):
Code:
[blue][Appointment].Form![TimeStampFieldName] = Now()[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
It clears the records but it's by passing my save command for some reason. I placed it in the onclick event. The save button is in the subform.
 
Mbarbine . . .

Hmmmm . . . post the code as you have it! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Mbarbine . . .

For saving have you tried:
Code:
[blue]   docmd.RunCommand acCmdSaveRecord[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 




Private Sub ApptSave_Click()


Dim errmsg
Dim errmsg1
Dim errmsg2
Dim errmsg3
Dim errmsg4
Dim errmsg5
Dim errmsg6


If Left(Me.AppointmentTime, 2) > "12" Then
errmsg = MsgBox("The time is incorrect! EXAMPLE: 01:23 AM", vbOKOnly, "Incorrect Time")
Me.AppointmentTime.SetFocus


ElseIf Right(Me.AppointmentTime, 1) <> "M" Then
errmsg1 = MsgBox("The time is incorrect! EXAMPLE: 01:23 AM", vbOKOnly, "Incorrect Time")
Me.AppointmentTime.SetFocus

' ElseIf Left(Me.AppointmentMHE, 5) Is Null Then
' errmsg2 = MsgBox("Please enter the MHE#! EXAMPLE: ForkLift C28 = MHE-028", vbOKOnly, "Invalid MHE#")
' DoCmd.GoToControl "AppointmentMHE"





Else

Me.AppointmentMHE = "MHE-" & Me.AppointmentMHE

If DCount("*", "dbo_MHE Equipment Report", "[Equipment#] = '" & Me![AppointmentMHE] & "'") < 1 Then DoCmd.Close acForm, "appointment", acSaveNo
If DCount("*", "dbo_MHE Equipment Report", "[Equipment#] = '" & Me![AppointmentMHE] & "'") < 1 Then errmsg = MsgBox("Please check the MHE# - Example: C28 = MHE-028", vbOKOnly, "Incorrect MHE#")
If DCount("*", "dbo_MHE Equipment Report", "[Equipment#] = '" & Me![AppointmentMHE] & "'") < 1 Then End
If DCount("*", "dbo_MHE Equipment Report", "[Equipment#] = '" & Me![AppointmentMHE] & "'") > 1 Then RunCommand acCmdSaveRecord



' me.AppointmentTime = hours & ":" & minutes


' 100 RunCommand acCmdSaveRecord


DoCmd.Close acForm, "appointment", acSaveNo
Forms!newdesign!Frame.SourceObject = "mainswitchboard"
Forms!newdesign!Frame.SourceObject = "Appointment"




' DoCmd.Close acForm, "Appointment"
' DoCmd.OpenForm "Appointment", , , , acFormAdd

55 End If


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top