Save record before lookup

G

Guest

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
--
 
G

Guest

Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub
 
G

Guest

Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

Ofer said:
Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


jackle said:
i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

jackle said:
Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

Ofer said:
Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


jackle said:
i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

I will try this tomorrow. My workday is already done. What should ultimately
happen is by clicking the Button, it would save the current record in the
frmMainEntry (which is linked to the tblMainEntry) and alert id this already
exists, so you can manually alter your number (with a -2 or a -3, etc.) After
the save, it would either have a message "Record Saved" (signifying there is
no record in the tblShortSheet) or open the frmShortSheet to see the matching
record.

I have an existing Save button. it works well for an error trap for
duplicate work orders in the frmMainEntry. One day i will have it so that
when you enter a work order number, it would automaticly assign the dash
series (i.e. -1 or -2 or -3). Currently the Work Order # in the frmMaindEntry
picks up the first 6 places in the the Inspection # textbox's string.
(clumbsy, but effective.)

A bit long winded but it might help you to know this.
If i have further questions tomorrow, i will start a new Post "Ofre, Re:
SAve Record". This may help avoid back trackeng a days worth of posts. OK?
Thanks, again,
jim
--

Ofer said:
For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

jackle said:
Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

Ofer said:
Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


:

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

I checked it out and it works. i did get a "The OpenForm action was
canceled." popup. i deleted the "Else Msgbox Err.Description" part
because of this popup. if it could be made to NOT popup fpr this action, that
would be the best but i don't know which error this is or how to suppress it.
If you do, great. If not it shopuld work very well. thank you VERY much.,
jim
--



jackle said:
I will try this tomorrow. My workday is already done. What should ultimately
happen is by clicking the Button, it would save the current record in the
frmMainEntry (which is linked to the tblMainEntry) and alert id this already
exists, so you can manually alter your number (with a -2 or a -3, etc.) After
the save, it would either have a message "Record Saved" (signifying there is
no record in the tblShortSheet) or open the frmShortSheet to see the matching
record.

I have an existing Save button. it works well for an error trap for
duplicate work orders in the frmMainEntry. One day i will have it so that
when you enter a work order number, it would automaticly assign the dash
series (i.e. -1 or -2 or -3). Currently the Work Order # in the frmMaindEntry
picks up the first 6 places in the the Inspection # textbox's string.
(clumbsy, but effective.)

A bit long winded but it might help you to know this.
If i have further questions tomorrow, i will start a new Post "Ofre, Re:
SAve Record". This may help avoid back trackeng a days worth of posts. OK?
Thanks, again,
jim
--

Ofer said:
For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

jackle said:
Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

:

Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


:

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

You can put a code break in the error section, when the code will stop, press
Ctrl+G to open the immidiate window and type ?err press enter and see the
value it returns.
After you get the error number you can write in the error capture
Iff err<>TheNumber then
msgbox err.description
end if

jackle said:
I checked it out and it works. i did get a "The OpenForm action was
canceled." popup. i deleted the "Else Msgbox Err.Description" part
because of this popup. if it could be made to NOT popup fpr this action, that
would be the best but i don't know which error this is or how to suppress it.
If you do, great. If not it shopuld work very well. thank you VERY much.,
jim
--



jackle said:
I will try this tomorrow. My workday is already done. What should ultimately
happen is by clicking the Button, it would save the current record in the
frmMainEntry (which is linked to the tblMainEntry) and alert id this already
exists, so you can manually alter your number (with a -2 or a -3, etc.) After
the save, it would either have a message "Record Saved" (signifying there is
no record in the tblShortSheet) or open the frmShortSheet to see the matching
record.

I have an existing Save button. it works well for an error trap for
duplicate work orders in the frmMainEntry. One day i will have it so that
when you enter a work order number, it would automaticly assign the dash
series (i.e. -1 or -2 or -3). Currently the Work Order # in the frmMaindEntry
picks up the first 6 places in the the Inspection # textbox's string.
(clumbsy, but effective.)

A bit long winded but it might help you to know this.
If i have further questions tomorrow, i will start a new Post "Ofre, Re:
SAve Record". This may help avoid back trackeng a days worth of posts. OK?
Thanks, again,
jim
--

Ofer said:
For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

:

Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

:

Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


:

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

I wrote IIf by mistake its If

jackle said:
I checked it out and it works. i did get a "The OpenForm action was
canceled." popup. i deleted the "Else Msgbox Err.Description" part
because of this popup. if it could be made to NOT popup fpr this action, that
would be the best but i don't know which error this is or how to suppress it.
If you do, great. If not it shopuld work very well. thank you VERY much.,
jim
--



jackle said:
I will try this tomorrow. My workday is already done. What should ultimately
happen is by clicking the Button, it would save the current record in the
frmMainEntry (which is linked to the tblMainEntry) and alert id this already
exists, so you can manually alter your number (with a -2 or a -3, etc.) After
the save, it would either have a message "Record Saved" (signifying there is
no record in the tblShortSheet) or open the frmShortSheet to see the matching
record.

I have an existing Save button. it works well for an error trap for
duplicate work orders in the frmMainEntry. One day i will have it so that
when you enter a work order number, it would automaticly assign the dash
series (i.e. -1 or -2 or -3). Currently the Work Order # in the frmMaindEntry
picks up the first 6 places in the the Inspection # textbox's string.
(clumbsy, but effective.)

A bit long winded but it might help you to know this.
If i have further questions tomorrow, i will start a new Post "Ofre, Re:
SAve Record". This may help avoid back trackeng a days worth of posts. OK?
Thanks, again,
jim
--

Ofer said:
For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

:

Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

:

Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


:

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 
G

Guest

Cool. Thanks for the heads up. All else works great!!
thanks for all the help.

jim
--

Ofer said:
I wrote IIf by mistake its If

jackle said:
I checked it out and it works. i did get a "The OpenForm action was
canceled." popup. i deleted the "Else Msgbox Err.Description" part
because of this popup. if it could be made to NOT popup fpr this action, that
would be the best but i don't know which error this is or how to suppress it.
If you do, great. If not it shopuld work very well. thank you VERY much.,
jim
--



jackle said:
I will try this tomorrow. My workday is already done. What should ultimately
happen is by clicking the Button, it would save the current record in the
frmMainEntry (which is linked to the tblMainEntry) and alert id this already
exists, so you can manually alter your number (with a -2 or a -3, etc.) After
the save, it would either have a message "Record Saved" (signifying there is
no record in the tblShortSheet) or open the frmShortSheet to see the matching
record.

I have an existing Save button. it works well for an error trap for
duplicate work orders in the frmMainEntry. One day i will have it so that
when you enter a work order number, it would automaticly assign the dash
series (i.e. -1 or -2 or -3). Currently the Work Order # in the frmMaindEntry
picks up the first 6 places in the the Inspection # textbox's string.
(clumbsy, but effective.)

A bit long winded but it might help you to know this.
If i have further questions tomorrow, i will start a new Post "Ofre, Re:
SAve Record". This may help avoid back trackeng a days worth of posts. OK?
Thanks, again,
jim
--

:

For the error capture I would add the err number, because it could be any error
3022
Err_btnIsPartOnShortSheet_Click:
If Err = 3022 then ' Duplicate
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate
Record"
Else
Msgbox Err.Description
End If
'Cancel = True no need for that
Resume Exit_btnIsPartOnShortSheet_Click

And I don't follow the problem you have with the on open event, it should
work fine.
If you want to check if there are records to be saved in the form, before
running the docmd save, then check the values in the field
If isnull(Me.Text1) or isnull(Me.Text2) then
msgbox "No data to be saved"
Exit sub
End if

Put this code before the line that you save the records.

:

Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?


Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click

End Sub

---- Code for OnOpen for opening form ------

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub


thnaks, again,
Jim

--

:

Try this

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


:

i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.

Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnIsPartOnShortSheet_Click:
Exit Sub

Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click

End Sub


thanks,
jim
 

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

Top