By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,762 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,762 IT Pros & Developers. It's quick & easy.

Save New Record - Tried all from prior posts

P: n/a
I have a simple app, and I'm trying to add Orders.

I have tblOrders and tblOrderDetails.

First, the user selects the customer, then "orders", "new Order"

The frmNewOrder simply assures the user she is on the right customer
and sets up an orderKey and orderNumber.

The user enters "Drop Off date", to make the form dirty, and to have
Access assign an OrderID.

Then the user presses "Add Services to Order".

The problem is that the Order record isn't saved. I've looked at prior
posts from as far back as 2001 and have tried all suggestions:
me.dirty = true
doCmd.RunCommand acCmdSaveRecord
Me.refresh
If me.dirty then
me.dirty=false
I have set the focus to the other control (misc notes) where the user
could enter date.

Nothing works. Some of these attempts have yielded the "can't add -
need a related record in tblCustomer" type message, and others have
taken me to the frmSelectService, but have not saved the record.

I am having the same problem on frmSelectService. It's bee 2.5 hours
now - maybe someone can help??

Code below:

Private Sub cmdAddService_Click()
On Error GoTo Err_cmdAddService_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim lngOrderID As Long
Dim dtmDropOffDate As Date

dtmDropOffDate = Me.txtDropOff
'
' ???*** Prefer to check here, but how???
' This code is not executed it drop off date is empty - only when it's
been filled in
' the error code executes when drop off date is empty
' If drop off date is empty, tell the user to put in the date
' Date is required to get the system to assign an Order ID and save
the record
If IsNull(Me.txtDropOff) Then
MsgBox "Please enter the drop off date for the items on this
order"
DoCmd.GoToControl (txtDropOff)
GoTo Exit_cmdAddService_Click
End If

' Save the order before opening the "add services" form
' Need to force the save - not happening automatically
' This code saves the new record before going to select services form
' If Me.Dirty Then
' Me.Dirty = False
' End If

Me.txtMiscNotes.SetFocus
Me.Dirty = True

DoCmd.RunCommand (acCmdSaveRecord)

' Me.Refresh

lngOrderID = Me.txtOrderID
stDocName = "frmSelectService"

stLinkCriteria = "[OrderID]= " & lngOrderID

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAddService_Click:
Exit Sub

Err_cmdAddService_Click:

' If drop off date is empty, tell the user to put in the date
' Date is required to get the system to assign an Order ID and save
the record
If Err.Number = 94 Then
MsgBox "Please enter the drop off date for the items on this
order"
Me.txtDropOff.SetFocus
GoTo Exit_cmdAddService_Click
End If

MsgBox Err.Number & " " & Err.Description
Resume Exit_cmdAddService_Click

End Sub

MANY thanks.
sara

Jan 22 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.