Re-opening Record

R

RobVT

Running MS Access 2003.
I have a set of two forms that I'm using to input new records into two
different tables. The first form asks for high-level project
information such as location, type, etc. This data is fed into a table
with the matching fields.

I have my forms set up such that when the user clicks "Continue", a
second form for more detailed project characteristics are collected.
The form that opens and the fields collected depends on the "Project
Type" entered on the previous form. When the user finishes filling out
the second form, this data is input into the appropriate table.

What I would like to do is put a "Back" button on the second form to
allow the user to modify his/her original information, incase they've
made a mistake along the way. However, when I go Back with my button,
I get a new blank form. The reason for this is that I have my form set
On Open, create a new record. I would like to modify this such that if
the original form is re-opened from the second form, the information
just input will show up for modification.

I've tried just changing the visibility of the forms but apparently
this acts the same as closing and reopening the form.

Any help is much appreciated. Thanks in advance!
 
R

Rick Brandt

RobVT said:
Running MS Access 2003.
I have a set of two forms that I'm using to input new records into two
different tables. The first form asks for high-level project
information such as location, type, etc. This data is fed into a
table with the matching fields.

I have my forms set up such that when the user clicks "Continue", a
second form for more detailed project characteristics are collected.
The form that opens and the fields collected depends on the "Project
Type" entered on the previous form. When the user finishes filling
out the second form, this data is input into the appropriate table.

What I would like to do is put a "Back" button on the second form to
allow the user to modify his/her original information, incase they've
made a mistake along the way. However, when I go Back with my button,
I get a new blank form. The reason for this is that I have my form
set On Open, create a new record. I would like to modify this such
that if the original form is re-opened from the second form, the
information just input will show up for modification.

I've tried just changing the visibility of the forms but apparently
this acts the same as closing and reopening the form.

Any help is much appreciated. Thanks in advance!

Why not just leave the first form open? Hiding it and showing it again
should NOT act the same as closing the form and reopening it. You have
something else going on if that is the case.

You can try this manually. Open the first form and make some entries then
go to the main menu and use Window - Hide. Wait a few seconds and then Use
Window - Unhide to display it again. It should be exactly as you left it.
Setting and resetting the Visible property with code should do exactly the
same thing.
 
R

RobVT

Well the Hide/Unhide method works, however, my Back button is still
doing the same thing. FYI, I have the initial form "Data Entry" set to
YES so that when I initally open the form I can't edit the existing
data in the table and so that I can immediately go to a new record.

I'm pretty sure this has something to do with it but I'm not sure.
Also, I double checked my Visible statements. On Click of the "Next"
button on the first form, I set the visibility of the initial form
equal to False, and the second form equal to true. My code for the
Back button on the second form sets the second form visible=false and
first form visible=true.

And as to why I don't leave the first form open, I guess it's just
personal preference. I'm hoping to make the database as simple as
possible for the end user so that data input is intuitive and they're
not distracted by extra windows being open.

Thanks for your reply and I appreciate your help.
 
R

Rick Brandt

RobVT said:
Well the Hide/Unhide method works, however, my Back button is still
doing the same thing. FYI, I have the initial form "Data Entry" set
to YES so that when I initally open the form I can't edit the existing
data in the table and so that I can immediately go to a new record.
[snip]

But DataEntry mode does not hide the record you just entered unless you
Requery the form (or close and re-open it). Please post the exact code in
your "Next" button and "Back" button.
 
R

RobVT

Rick,

This is the code for my "Next" button. As you can tell I have a
summary section on my subform that allows the user to review what they
input on the first form.
Private Sub cmdNextInput_Click()

If IsNull(Project_Number) Or IsNull(Project_Type) Or IsNull(District)
Or IsNull(Residency) Or IsNull(GS_Code) Or IsNull(AdMonth) Or
IsNull(Traffic_Volume_ADT_) Or IsNull(Award_Price) Then
Response = MsgBox("Please enter AT LEAST the Project Number,
Project Type, District, Residency, Geometric Standard Code, Advertised
Month, Traffic Volume, and Award Price!", vbCritical, "Entry Error")

If Response = vbOK Then GoTo 10

Else
Forms![Info Input Form].Visible = False

If Me.Project_Type.Value = "Widening" Then
DoCmd.OpenForm "PC WideningInput"
Forms![PC WideningInput]![Project Number].Value =
Forms![Info Input Form]![Project Number].Value
Forms![PC WideningInput]![txtProjType].Value =
Forms![Info Input Form]![Project Type].Value
Forms![PC WideningInput]![txtDistrict].Value =
Forms![Info Input Form]![District].Value
Forms![PC WideningInput]![txtResidency].Value =
Forms![Info Input Form]![Residency].Value
Forms![PC WideningInput]![txtCounty].Value =
Forms![Info Input Form]![County].Value
Forms![PC WideningInput]![txtCity].Value = Forms![Info
Input Form]![City].Value
Forms![PC WideningInput]![txtGeoStandard].Value =
Forms![Info Input Form]![GS Code].Value
Forms![PC WideningInput]![txtAdMonth].Value =
Forms![Info Input Form]![AdMonth].Value
Forms![PC WideningInput]![txtTrafficVolume].Value =
Forms![Info Input Form]![Traffic Volume (ADT)].Value
Forms![PC WideningInput]![txtEstCost].Value =
Forms![Info Input Form]![Award Price].Value
Forms![PC WideningInput]![Project Number].SetFocus
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
End If

10 End If

End Sub


"Back" button code:

Private Sub cmdWidenBack_Click()

Forms![Info Input Form].Visible = True
Forms![PC WideningInput].Visible = False

End Sub

PS: Sorry for the sloppy look.
 
R

RobVT

Rick,

I figured out how I can make it work. I added a line of code to go to
the previous record upon "re-opening" the intro form. When I do that,
I get back to the data I'd just put in.

Thanks for your help!
 
R

Rick Brandt

RobVT said:
Rick,

I figured out how I can make it work. I added a line of code to go to
the previous record upon "re-opening" the intro form. When I do that,
I get back to the data I'd just put in.

Thanks for your help!

You have a line near the bottom of your Next code...

DoCmd.GoToRecord acDataForm, Me.Name, acNewRec

That line is telling your form to go to a new record after you have hidden it.
Just take that out.
 

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