473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Using Form instead of message box

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
7 2228
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
5
by: RichG | last post by:
I'm looking for a way to bring an open form to the top. I know that is I open a form directly with form1.show() and then later, while the form is open I do another form1.show(), that I will get...
6
by: tony | last post by:
Hello! When exactly is it important or advisable to use this form load event handler compare to using the C-tor. For example here I create an event handler called dataBoundGridForm that is...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.