Refresh/Repaint subform (1 Viewer)

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
I have a popup form, whose result value is used on a form. I then want to refresh a subform linked to this value.
A requery is not good, because I don't want to prompt the user to update. The refresh/repaint of the subform does not work well.

In Main Form:
DoCmd.OpenForm strPopupForm, WindowMode:=acDialog
If IsFormOpen(strPopupForm) Then
Me![High School ID] = Forms(strPopupForm).lbSchool
DoCmd.Close acForm, strPopupForm
' Me.Repaint
' Me.High_School_SubForm.Refresh
End If
Me![HS Type].SetFocus


Thanks!
Norm.
 

WayneRyan

AWF VIP
Local time
Today, 07:49
Joined
Nov 19, 2002
Messages
7,122
Norm,

I think that you need "Me.High_School_SubForm.ReCalc" here.

Wayne
 

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
Sorry, tried that already and received a 'method not found' error message.

I also tried a docmd.repaintobject, but it complained the object is not open.
DoCmd.RepaintObject acForm, "High School SubForm"
 

Mod

DoCmd.PostForHelp
Local time
Today, 01:49
Joined
May 4, 2004
Messages
70
stormin_norm said:
I have a popup form, whose result value is used on a form. I then want to refresh a subform linked to this value.
A requery is not good, because I don't want to prompt the user to update. The refresh/repaint of the subform does not work well.

In Main Form:
DoCmd.OpenForm strPopupForm, WindowMode:=acDialog
If IsFormOpen(strPopupForm) Then
Me![High School ID] = Forms(strPopupForm).lbSchool
DoCmd.Close acForm, strPopupForm
' Me.Repaint
' Me.High_School_SubForm.Refresh
End If
Me![HS Type].SetFocus


Thanks!
Norm.
Um, is this all in one function? I don't think you need any refresh, requery, or repaint for this

Me![High School ID] is a text box, right? the changes should be immediate. It could be that control isn't reaching that branch. (allthough i assume you checked for that).

I would put a button in your pop up form with the caption "Close" and make its onclick event like this: (this is a popup not a subform, right?)
Code:
Private Sub CmdClose_OnClick()
Form_Original.TxtHighSchoolID = Me.CboHighSchoolChosen
DoCmd.Close acForm, me.name, acSaveNo
End Sub
 
R

Rich

Guest
Your references to the main form and sub form are incorrect, use the code builder to get the correct syntax and then use the Requery method
 

Mod

DoCmd.PostForHelp
Local time
Today, 01:49
Joined
May 4, 2004
Messages
70
Rich said:
Your references to the main form and sub form are incorrect, use the code builder to get the correct syntax and then use the Requery method
ick. His or mine? i've been using that syntax throughout my whole project, but if its bad form i'll change it.
 

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
Rich/Mod-

Yes the TxtHighSchoolID is getting populated by the popup result. BUT Now I need the subform which is linked to the TxtHighSchoolID to refresh/requery using this new value of TxtHighSchoolID.

The rub- I can't do a Me.Requery because that causes the whole recordset to requery and then prompt the user Y/N to save changes. All the user did was lookup a school name, change the value of the ID in the recordset, and should see this new school chosen in the subform.
The user should not "HAVE TO" save changes...yet..
 

Mod

DoCmd.PostForHelp
Local time
Today, 01:49
Joined
May 4, 2004
Messages
70
Well, if your major concern is keeping the pop-up box about update queries from appearing, i recommend:
Code:
DoCmd.SetWarnings False
'The rest of your code
DoCmd.SetWarnings True
 

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
Rich said:
Your references to the main form and sub form are incorrect, use the code builder to get the correct syntax and then use the Requery method

Rich-
Trial and error. Yes the nomenclature is the issue. I'm still getting the main form giving me grief. As soon as the SetFocus executes I get the main form giving me the update message.
I need the SetFocus, otherwise the subform NEVER shows the correct record. The recordset is still holding the old ID (link mainform to subform).

Shouldn't I be able to change the ID# on the mainform and then force the subform to requery WITHOUT having to update the main form's recordset?

DoCmd.SetWarnings False
Me![High School SubForm].SetFocus
Me![High School SubForm].Requery
DoCmd.SetWarnings True

-----------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (MsgBox("Update this record?", vbQuestion + vbYesNo, "Record modified") = vbNo) Then
Me.Undo
Cancel = True
End If
End Sub
 
R

Rich

Guest
I'm having a hard time trying to figure out what you're trying to do, but it looks as though you just want to go to the record selected on the popup, in which case why are you requerying the subform?
 

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
Rich said:
I'm having a hard time trying to figure out what you're trying to do, but it looks as though you just want to go to the record selected on the popup, in which case why are you requerying the subform?

Thanks for your help Rich, Mod and WayneRyan! I greatly appreciate it.

The popup gets the school ID, and this school ID is held in the recordset as ID. This ID is linked to a subform which holds all the detail information about the school. The idea is if you are browsing students, you would view their school info, no need for the popup. But if you wish to enter a new student you need the popup to locate the school (name,city,state).

It is almost sounding like I need to be in the subform to trigger the popup, and not on the main form. OR I have to rework the subform to do both the lookup function and presentation of data. Although screen space is limited, thats why I like the popup. You can view multiple names of schools and pick the correct one vs. scrolling through them in a subform.
 

stormin_norm

Registered User.
Local time
Today, 02:49
Joined
Apr 23, 2003
Messages
213
WayneRyan said:
Norm,

I think that you need "Me.High_School_SubForm.ReCalc" here.

Wayne

Thanks all. I knew this had to work sooner or later ;)
I found the problem was two fold 1) The field [High School ID] was no longer on the main form. So the recordset would get the update, but the form which is linking to the subform did not recognize the change in value. In otherwords...the value in the recordset did not drive the subform update until a requery was run (save record). Which is why I was getting so annoyed at those update messages. I was hunting for the field [High School ID] on another tab page, but couldn't find it! So added it back to the main form. Then used recalc and it worked GREAT! I had to modify the syntax as follows: me.subform.form.recalc

THANKS EVERYONE!

here is the working code:

If (..yada yada yada...)
Me.High_School_ID = Forms(strPopupForm).lbSchool
DoCmd.Close acForm, strPopupForm
Me.High_School_SubForm.Form.Recalc
' Me![High School SubForm].Form.Recalc -- Also okay syntax
End If
Me![HS Type].SetFocus
 
Last edited:

Users who are viewing this thread

Top Bottom