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

Using Form instead of message box

P: n/a
RC
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was
clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.

Nov 13 '05 #2

P: n/a
RC
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was
clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.

Nov 13 '05 #3

P: n/a
You're close.
I think I'd write the code more like this:

select case Forms!myPopupDialogForm.ActiveControl.name
case "MakeChanges "
rs.update
case "DontMakeChanges"
Me.Undo
End select

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message

news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.

Nov 13 '05 #4

P: n/a
RC
OK, I got the code below to work, but, let's say the codes jumps to
the MakeChangesLine: and you edit and update the record THEN the code
continues along and skips over the DontMakeChangesLine: line and then
executes the next line of code which is form.undo
I don't understand how to use the "goto" statement, is there a way to
write this so it doesn't execute the form.undo line?
-----------------------
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Forms!DisplayItemInformationForm.ActiveControl

If ctlCurrentControl.Name = "ChangeDataButton" Then
GoTo MakeChangesLine:
If ctlCurrentControl.Name = "DontChangeDataButton" Then
GoTo DontMakeChangesLine:

MakeChangesLine:
this is where I edit and update the record

DontMakeChangesLine:
form.undo
rc*********@yahoo.com (RC) wrote in message news:<3c**************************@posting.google. com>...
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was
clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.

Nov 13 '05 #5

P: n/a
RC
Should I use Select Case instead of goto?

rc*********@yahoo.com (RC) wrote in message news:<3c**************************@posting.google. com>...
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was
clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
When I am adding records to a database and each record is unique by
the Serial Number. I would like to step through my code adding
records unless the Serial Number already exists in the database. If
the record already exits, then I would like to pop up a form, in
pop-up, dialog mode. The form will ask if the user wants to make
changes to the existing record and go back to the form and not make
any changes. The code stops because the pop up form is "dialog" but I
want to return to a certain line in the code depending which button
the user selected on the pop-up form or somehow react to which button
the user picked on the pop-up form not just return and continue
processing the code where it left off.

Nov 13 '05 #6

P: n/a
The answer to "Should I use <anything> instead of GoTo?" is generally "yes",
with the possible exception of error handling.

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
Should I use Select Case instead of goto?

rc*********@yahoo.com (RC) wrote in message

news:<3c**************************@posting.google. com>...
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
> When I am adding records to a database and each record is unique by
> the Serial Number. I would like to step through my code adding
> records unless the Serial Number already exists in the database. If
> the record already exits, then I would like to pop up a form, in
> pop-up, dialog mode. The form will ask if the user wants to make
> changes to the existing record and go back to the form and not make
> any changes. The code stops because the pop up form is "dialog" but I > want to return to a certain line in the code depending which button
> the user selected on the pop-up form or somehow react to which button > the user picked on the pop-up form not just return and continue
> processing the code where it left off.

Nov 13 '05 #7

P: n/a
RC
THANKS !! It worked like a charm! When I typed the Select Case line
and I got to the period after "ActiveControl", I thought I was only
able to use the choices presented in the VB Editor drop down box, but
even though "name" was not one of the options, it worked fine.

"MacDermott" <ma********@nospam.com> wrote in message news:<Ar*****************@newsread2.news.atl.earth link.net>...
You're close.
I think I'd write the code more like this:

select case Forms!myPopupDialogForm.ActiveControl.name
case "MakeChanges "
rs.update
case "DontMakeChanges"
Me.Undo
End select

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
Thanks for the reply, is this the way to do what you are saying?

If the user clicks on the "MakeChanges" Button or the
"DontMakeChanges" Button, I have the onclick property for those
buttons change the popup dialog form to invisible, then my code
resumes where I left off, but, at that point I put a line of code
like:

If Forms!myPopupDialogForm.ActiveControl = MakeChanges then goto line
22
End If

If Forms!myPopupDialogForm.ActiveControl = DontMakeChanges then goto
line 33
EndIf

Line 22
rs.update

Line 33
Form.Undo

"MacDermott" <ma********@nospam.com> wrote in message

news:<TO*****************@newsread2.news.atl.earth link.net>...
Remove the X in the upper right of your dialog (that's the CloseButton
property of the form), so the user must select one of your buttons.
In the code behind those buttons, don't close the dialog -
set its Visible property to False instead.
Code execution will resume on your main form right after your
DoCmd.OpenForm.
You can check your dialog's ActiveControl property to see which button was clicked, and branch accordingly.

HTH
- Turtle

"RC" <rc*********@yahoo.com> wrote in message
news:3c**************************@posting.google.c om...
> When I am adding records to a database and each record is unique by
> the Serial Number. I would like to step through my code adding
> records unless the Serial Number already exists in the database. If
> the record already exits, then I would like to pop up a form, in
> pop-up, dialog mode. The form will ask if the user wants to make
> changes to the existing record and go back to the form and not make
> any changes. The code stops because the pop up form is "dialog" but I
> want to return to a certain line in the code depending which button
> the user selected on the pop-up form or somehow react to which button
> the user picked on the pop-up form not just return and continue
> processing the code where it left off.

Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.