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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a form when new record added

Status
Not open for further replies.

domino3

MIS
May 20, 2003
307
GB
I have a form with a subform in it, which has a print button on the main form. The main form has a refresh button on it which makes any changes to an existing record before the record is printed out for the record on the screen. What is doesn't do is print out the record if it has just been added, which means that the user has to add the record, go into a different record, then go back to the record just created before they can print it out. Can anyone tell me how to refresh a new record to make it appear without having to come out of that record first. Hope that makes sense. Thank you.
 
try me.requery, works in most situations...

--------------------
Procrastinate Now!
 
Thanks for the reply. I've tried refresh rather than requery and the new info is saved and the new record added to the drop down combo list, but then goes back to the first record, rather than stay in the record already selected. I aslo get error message to tell me that the system can't find the current record.

Also, the printout that can then be run from a button on the form doesn't find the new record as it needs the new record to have been selected on the combo list to work.

I've now tried adding a bookmark to the code to remember the current recordset on screen before the refreh is done. However, I can't work out how to get the bookmark to then pick the required record from the combo box. I get an error message to tell me The code I have is below:

Private Sub Command1057_Click()
On Error GoTo Err_Command1057_Click

Dim rs As dao.Recordset
Set rs = Me.RecordsetClone

Me.Refresh

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Me.Bookmark = rs.Bookmark
Exit_Command1057_Click:
Exit Sub

Err_Command1057_Click:
MsgBox Err.Description
Resume Exit_Command1057_Click

End Sub

What I need is the ID No from the bookmarked recordset to be added into the combo box selection. Any ideas on how this could be done would be much appreciated. Thank you.
 
I have a further thought on how to get the combo box selected, but don't know if this is the right way to go about it. I wondered if the way to go was to have a button to click which requeries. the form with he new record on, then tries to find the record on the combo box list. I've tried the code below to select the id_no from the combo box, but am getting an error.

Private Sub Command1057_Click()
On Error GoTo Err_Command1057_Click

Me.Requery

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.GoToControl "ID"
DoCmd.FindRecord Combo_newparent, acEntire, False, , False, acCurrent, TrueExit_Command1057_Click:
Exit Sub

Err_Command1057_Click:
MsgBox Err.Description
Resume Exit_Command1057_Click

End Sub

It doesn't like TrueExit_Command1057_Click: but I don't understand why. I'd be grateful for any help given. Thank you.
 
Just add a save to the beginning of the print button:

DoCmd.RunCommand accmdSaveRecord

TrueExit_Command1057_Click would not work because it is too lines lumped into one. Put a line break after True.

Requery won't help when a record s not saved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top