Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form not to update

Status
Not open for further replies.

Allilue

Technical User
Sep 14, 2000
189
GB
I have a form with a table as a record source. I have the fields in the form set as unbound. Is there a way for me to select records and make inputs without affecting the orinating table until I click an Update button? And how do I update it so that the input goes into the originating table?

Ex. Table - Name, Address, Phone#
Form to select name from combo box
Address and phone # to input
click update button to add record, not to replace the original name, but to add a new record with "New" & Original name as the new name.
 
Make your fields bound to your table. You can lock them if you don't want users to actually touch them. Your combo must include all fields you want to move:
In the "After update" event for the combo add something like:
Me![NameOfTheFieldIWantToSendDataTo].DefaultValue = Me![NameOfCombo].Column(1)
Me![NameOfAnotherFieldIWantToSendDataTo].DefaultValue = Me![NameOfCombo].Column(2)

(Remember combos are zero based so the first column from the query is "0"...)

So now you've dumped your data into your bound fields "default value", have your Update button do something like:
DoCmd.GoToRecord , , acNewRec
Docmd.Runcommand acCmdSaveRecord

I think this will work for you...
Gord
ghubbell@total.net
 
Ok, my fields are bound to my table. But I am still having difficulty when I don't want the form to update my table. When selecting from the first combo box for Name, I have added "New" in front to make it distinct from the original Name in the table. Then I enter other info bound to the table. But this automatically enters the data into the table as a new record (which is what I want). But I want the user to have the option to exit the form WITHOUT saving the data, or without updating the table.

Thanks!
 
Remove the line:
Docmd.Runcommand acCmdSaveRecord

Then you could add a command button (wizard built) to undo the record or build your own and add these lines:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdUndo
Gord
ghubbell@total.net
 
Hi....me again.

I put this in and it is working...however, I'd like to add some things after the record saves. How do I make it so that after the save, the form closes and another opens. I'm not sure where to place the code and nothing I do seems to work! Sorry!

Private Sub AddName_Click()
On Error GoTo Err_AddName_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_AddName_Click:
Exit Sub

Err_AddName_Click:
MsgBox Err.Description
Resume Exit_AddName_Click

End Sub
 
A: No sorries! B: Everything you've done is working! Copy this in to your module (I replaced your save line with one that we can understand):

Private Sub AddName_Click()
On Error GoTo Err_AddName_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
DoCmd.OpenForm "TheNameOfTheFormYouWantToOpen"

Exit_AddName_Click:
Exit Sub

Err_AddName_Click:
MsgBox Err.Description
Resume Exit_AddName_Click
End Sub

and add in the name of the form that you want to open!
Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top