Command Button help

G

Guest

I’d like to combine the following 2 buttons into 1 button. In addition to
that, I’d like it to NOT open the form (in the Short Sheet Compare Button) if
there is not match. That is, save the record and open the form if only there
is a match. The purpose of the save function is to error check to make sure
there is not a duplicate record.

If anyone can hazard a new code or rework this, please help. This will help
me on future projects.

SHORT SHEET COMPARE BUTTON

Private Sub btnCheckShortSheet_Click()
On Error GoTo Err_btnCheckShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

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

Exit_btnCheckShortSheet_Click:
Exit Sub

Err_btnCheckShortSheet_Click:
MsgBox Err.Description
Resume Exit_btnCheckShortSheet_Click

End Sub



SAVE RECORD BUTTON

Private Sub SaveRecord_Click()
On Error GoTo Err_SaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRecord_Click:
Exit Sub

Err_SaveRecord_Click:
MsgBox Err.Description
Resume Exit_SaveRecord_Click

End Sub
 
G

Guest

I am not sure I understand your process here....

What I think you need is to ensure the table does not allow duplicates (if
that is the case) rather than run an event to check for them. Then when the
user tries the save the record, they will be prompted that a duplicate exists
and they will need to make a change to the work order # before proceeding.

As far as opening the form, are you suggesting that the same input be used
to save a new record AND open an existing one? If you save a record and then
ask it to open any matches, you should get the one you just saved. However,
if you enter a work order that exists, you will get the duplicate error and
be forced to change the work order number in order to continue, therefor
never reaching the open form part of the code.

But like I said, perhaps I have the logic wrong.

Can you provide more details?

Cheers
 
G

Guest

Yeah, it'd be nice to fix the duplicate issue. There is so much going on on
the button that controls the Woer Order text block that we could fix that.
BTW, to make a unique ID for the work order, the Inspection number is a
unique #. It is the 6 digit work order then a hypehen and a number denoting
which passthru has been made. if you type in 455891-1 and get a duplicate,
just change the 1 to a 2. It is rare for that though.

It might help you to understand that the Work Order Form that has the
command buttons is not the same table as the Short Sheet Table. We can have
thousands of Workorders but only 50 - 150 Work orders on the Short Sheet
(Expedites). So, the form that shows the Short Sheet is not the same as the
Work Order Form. It is not actually searching for "duplicates," per se. It's
just seing if a Work Order is being flagged as Expedite. I guess i didn't
make it very clear.

Thanks for any additional help.
Jim
--



Paul B. said:
I am not sure I understand your process here....

What I think you need is to ensure the table does not allow duplicates (if
that is the case) rather than run an event to check for them. Then when the
user tries the save the record, they will be prompted that a duplicate exists
and they will need to make a change to the work order # before proceeding.

As far as opening the form, are you suggesting that the same input be used
to save a new record AND open an existing one? If you save a record and then
ask it to open any matches, you should get the one you just saved. However,
if you enter a work order that exists, you will get the duplicate error and
be forced to change the work order number in order to continue, therefor
never reaching the open form part of the code.

But like I said, perhaps I have the logic wrong.

Can you provide more details?

Cheers



jackle said:
I’d like to combine the following 2 buttons into 1 button. In addition to
that, I’d like it to NOT open the form (in the Short Sheet Compare Button) if
there is not match. That is, save the record and open the form if only there
is a match. The purpose of the save function is to error check to make sure
there is not a duplicate record.

If anyone can hazard a new code or rework this, please help. This will help
me on future projects.

SHORT SHEET COMPARE BUTTON

Private Sub btnCheckShortSheet_Click()
On Error GoTo Err_btnCheckShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

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

Exit_btnCheckShortSheet_Click:
Exit Sub

Err_btnCheckShortSheet_Click:
MsgBox Err.Description
Resume Exit_btnCheckShortSheet_Click

End Sub



SAVE RECORD BUTTON

Private Sub SaveRecord_Click()
On Error GoTo Err_SaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRecord_Click:
Exit Sub

Err_SaveRecord_Click:
MsgBox Err.Description
Resume Exit_SaveRecord_Click

End Sub
 
G

Guest

Okay then, that makes it a little better to follow...

Does this sound like the process you want:

1) User enters a work order number
2) Check for duplicates
3) If duplicate, prompt user that a work order already exists and
a) offer to change WO#
b) append existing WO# with the -1 -2 etc
c) cancel entry
4) Save new record
5) Look for WO# in Expedite table
6) If match, show order


Let me know and I'll see what I can do for you next week. I am short on time
this afternoon.

Cheers


jackle said:
Yeah, it'd be nice to fix the duplicate issue. There is so much going on on
the button that controls the Woer Order text block that we could fix that.
BTW, to make a unique ID for the work order, the Inspection number is a
unique #. It is the 6 digit work order then a hypehen and a number denoting
which passthru has been made. if you type in 455891-1 and get a duplicate,
just change the 1 to a 2. It is rare for that though.

It might help you to understand that the Work Order Form that has the
command buttons is not the same table as the Short Sheet Table. We can have
thousands of Workorders but only 50 - 150 Work orders on the Short Sheet
(Expedites). So, the form that shows the Short Sheet is not the same as the
Work Order Form. It is not actually searching for "duplicates," per se. It's
just seing if a Work Order is being flagged as Expedite. I guess i didn't
make it very clear.

Thanks for any additional help.
Jim
--



Paul B. said:
I am not sure I understand your process here....

What I think you need is to ensure the table does not allow duplicates (if
that is the case) rather than run an event to check for them. Then when the
user tries the save the record, they will be prompted that a duplicate exists
and they will need to make a change to the work order # before proceeding.

As far as opening the form, are you suggesting that the same input be used
to save a new record AND open an existing one? If you save a record and then
ask it to open any matches, you should get the one you just saved. However,
if you enter a work order that exists, you will get the duplicate error and
be forced to change the work order number in order to continue, therefor
never reaching the open form part of the code.

But like I said, perhaps I have the logic wrong.

Can you provide more details?

Cheers



jackle said:
I’d like to combine the following 2 buttons into 1 button. In addition to
that, I’d like it to NOT open the form (in the Short Sheet Compare Button) if
there is not match. That is, save the record and open the form if only there
is a match. The purpose of the save function is to error check to make sure
there is not a duplicate record.

If anyone can hazard a new code or rework this, please help. This will help
me on future projects.

SHORT SHEET COMPARE BUTTON

Private Sub btnCheckShortSheet_Click()
On Error GoTo Err_btnCheckShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

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

Exit_btnCheckShortSheet_Click:
Exit Sub

Err_btnCheckShortSheet_Click:
MsgBox Err.Description
Resume Exit_btnCheckShortSheet_Click

End Sub



SAVE RECORD BUTTON

Private Sub SaveRecord_Click()
On Error GoTo Err_SaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRecord_Click:
Exit Sub

Err_SaveRecord_Click:
MsgBox Err.Description
Resume Exit_SaveRecord_Click

End Sub
 
G

Guest

Please see below, in your area. my comments are in upper case. Basicly the
New command button will execute the steps 2-6. Thanks, I look forward to any
help you are willing to offer.
jim
--



Paul B. said:
Okay then, that makes it a little better to follow...

Does this sound like the process you want:

1) User enters a work order number
2) Check for duplicates THIS OCCURS AS A PART OF THE SAVE RECORD BUTTON. IF I GET THE POPUP, I CLICK THE OK BUTTON AND AN DO THE EDIT. AND DO ANOTHER SAVE RECORD.
3) If duplicate, prompt user that a work order already exists and
a) offer to change WO#
b) append existing WO# with the -1 -2 etc
c) cancel entry
4) Save new record
5) Look for WO# in Expedite table
6) If match, show order IF NO MATCH, NOTHING WILL BE DISPLAYED. I WONDER IF A POPUP SAYING "RECORD SAVED" WILL ACT LIKE AN ERROR HANDLER. I MEAN THAT YOU EITHER GET THE "RECORD SAVED" POPUP OR YOU GET THE SHORTSHEET FORM SHOWING THAT RECORDS. WOULD THAT BE EASY TO ADD?


Let me know and I'll see what I can do for you next week. I am short on time
this afternoon.

Cheers


jackle said:
Yeah, it'd be nice to fix the duplicate issue. There is so much going on on
the button that controls the Woer Order text block that we could fix that.
BTW, to make a unique ID for the work order, the Inspection number is a
unique #. It is the 6 digit work order then a hypehen and a number denoting
which passthru has been made. if you type in 455891-1 and get a duplicate,
just change the 1 to a 2. It is rare for that though.

It might help you to understand that the Work Order Form that has the
command buttons is not the same table as the Short Sheet Table. We can have
thousands of Workorders but only 50 - 150 Work orders on the Short Sheet
(Expedites). So, the form that shows the Short Sheet is not the same as the
Work Order Form. It is not actually searching for "duplicates," per se. It's
just seing if a Work Order is being flagged as Expedite. I guess i didn't
make it very clear.

Thanks for any additional help.
Jim
--



Paul B. said:
I am not sure I understand your process here....

What I think you need is to ensure the table does not allow duplicates (if
that is the case) rather than run an event to check for them. Then when the
user tries the save the record, they will be prompted that a duplicate exists
and they will need to make a change to the work order # before proceeding.

As far as opening the form, are you suggesting that the same input be used
to save a new record AND open an existing one? If you save a record and then
ask it to open any matches, you should get the one you just saved. However,
if you enter a work order that exists, you will get the duplicate error and
be forced to change the work order number in order to continue, therefor
never reaching the open form part of the code.

But like I said, perhaps I have the logic wrong.

Can you provide more details?

Cheers



:

I’d like to combine the following 2 buttons into 1 button. In addition to
that, I’d like it to NOT open the form (in the Short Sheet Compare Button) if
there is not match. That is, save the record and open the form if only there
is a match. The purpose of the save function is to error check to make sure
there is not a duplicate record.

If anyone can hazard a new code or rework this, please help. This will help
me on future projects.

SHORT SHEET COMPARE BUTTON

Private Sub btnCheckShortSheet_Click()
On Error GoTo Err_btnCheckShortSheet_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mform_Short Sheet1 Query"

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

Exit_btnCheckShortSheet_Click:
Exit Sub

Err_btnCheckShortSheet_Click:
MsgBox Err.Description
Resume Exit_btnCheckShortSheet_Click

End Sub



SAVE RECORD BUTTON

Private Sub SaveRecord_Click()
On Error GoTo Err_SaveRecord_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_SaveRecord_Click:
Exit Sub

Err_SaveRecord_Click:
MsgBox Err.Description
Resume Exit_SaveRecord_Click

End Sub
 

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