Open Form2 from Form1, Close Form2 = Form1 values have #Name (1 Viewer)

twcaddell

Registered User.
Local time
Today, 15:24
Joined
Apr 8, 2013
Messages
31
I have two forms
First form is built from a query built of 5 tables to get data needed
Form 1 uses an unbounded combo box to traverse the records in the query

I have a second form that is opened up by a button click. It calls one of the tables used in the query so that the user can edit the data if needed. When I close this second form and return to the first form, all the fields show the #Name error in the txt boxes. If I use the combo box to change records, no change in the errors and I must close the box and reopen to get functionality back.

I have tried several code changes. Here is my last

Code:
Private Sub CloseBtn_Click()
Dim povalue As String
   povalue = Me.PrintOrder 'PrintOrder was used in the First form to modify the sql statement in the record source
   DoCmd.Close
   Forms![Open Print Orders Form].POCombo.Value = povalue 'Tried to set the print order back to the original value
   
   Forms![Open Print Orders Form].Refresh
   
End Sub

Any help or suggestions would be greatly appreciated.
Thanks
TC:D
 

HiTechCoach

Well-known member
Local time
Today, 15:24
Joined
Mar 6, 2006
Messages
4,357
Try changing this:

Code:
Forms![Open Print Orders Form].Refresh

to

Code:
Forms![Open Print Orders Form].Requery

Let us know if that works.
 

twcaddell

Registered User.
Local time
Today, 15:24
Joined
Apr 8, 2013
Messages
31
Unfortunately, it did not. I thought of a work around. I'm going to place a subform in for the data that needs to be editable. Thanks for the suggestion though:)

TC
 

boblarson

Smeghead
Local time
Today, 13:24
Joined
Jan 12, 2001
Messages
32,059
I would suggest a couple of other changes.

Code:
Private Sub CloseBtn_Click()
    Dim povalue As String
 
[B]   If Me.Dirty Then[/B]
[B]       Me.Dirty = False[/B]
[B]   End If[/B]
 
    povalue = Me.PrintOrder    'PrintOrder was used in the First form to modify the sql statement in the record source
    Forms![Open Print Orders Form].POCombo.value = povalue    'Tried to set the print order back to the original value
    Forms![Open Print Orders Form].[B]Requery[/B]
 
[B]   DoCmd.Close , acForm, Me.Name, acSaveNo[/B]
End Sub
 

Users who are viewing this thread

Top Bottom