Pull Data for a Update form

  • Thread starter Thread starter PJ
  • Start date Start date
P

PJ

I have a database where users can view information through forms and if
they need to update or change data, they need to print out a request,
that needs to be verified and then signed off on by thier supervisor.
As it is now, they press a button on the main form called update and a
blank form with all the fields from the main viewable screen pops up.
They fill in the data and print it out. My question is, is there a way
to have this update form pull the currently viewed data from the
viewable form that they can then go into on the update form and make
changes to with out changing the original data? Some query or method?
Thanks.
 
Hi,


That is doable, but required some VBA code.

You can open a form with a where clause restrictive to display only the
record where the primary key of the data to be displayed by the form matches
the primary key of the record you actually see. The where condition is one
of the optional arguments of the DoCmd.OpenForm.


Next, hide (visible =false) the bound controls on the new form, and create a
set of unbound controls that duplicate the first controls you just hide.
Push the data from the bound controls to the unbound control (in the
onCurrent event). Since the unbound control have no live link to the
database, changing the data in them won't change the data in the database.
But that means that the printed data won't be internally stored in the
database either... which does not appear to be the usual practice.



Hoping it may help,
Vanderghast, Access MVP
 
Thanks Vanderghast, this is the code I have for the button that opens
the update form called: BLANK_USER_UPDATE. ID is the primary key that I
would like to match to. I am not sure this is even correct but it is
from the wizard:

Private Sub MAKE_NEW_Click()
On Error GoTo Err_MAKE_NEW_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BLANK_USER_UPDATE"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_MAKE_NEW_Click:
Exit Sub

Err_MAKE_NEW_Click:
MsgBox Err.Description
Resume Exit_MAKE_NEW_Click

End Sub

I am unsure how to use your suggestion on the pushing data to the
unbound form though. The user update form is unbound at this point, can
you provide a little more guidance? Thanks in advance!
 
Thanks Michel,

This is the code I have for the button that opens the update form
called: BLANK_USER_UPDATE. ID is the primary key that I would like to
match to. I am not sure this is even correct but it is from the wizard:


Private Sub MAKE_NEW_Click()
On Error GoTo Err_MAKE_NEW_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BLANK_USER_UPDATE"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_MAKE_NEW_Click:
Exit Sub

Err_MAKE_NEW_Click:
MsgBox Err.Description
Resume Exit_MAKE_NEW_Click

End Sub

I am unsure how to use your suggestion on the pushing data to the
unbound form though. The user update form is unbound at this point, can
you provide a little more guidance? Thanks in advance!
 
Hi,



I still assume you don't want the modifications to be saved, ever.

I assume you have three fields, ID, ClientName, ClientOther.

Have the Form Blank_User_Update with 3 controls, same name as the previous
fields. Have these control hidden (visible = false)

Add 3 new controls, ID_1, ClientName_1, ClientOther_1. Do not bind them to
the fields!


In the onCurrent procedure event for the form, add the following code:


Me.ID_1=Me.ID
Me.ClientName_1 = Me.ClientName
Me.ClientOther_1 = Me.ClientOther



Since the end user only see the three _1 controls, and that these are not
bound to the fields, whatever modification is done to them by the end user
won't be saved, ever, in the table, but their data would reflect what is
already in the table (though the controls without the _1, which *are* bound
the data in the table)



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top