Refreshing a Value on a Form

aziz rasul

Active member
Local time
Today, 07:47
Joined
Jun 26, 2000
Messages
1,935
I have a form called "frmGeneralEnquiries" which is opened to a new blank record with some mandatory fields. The record has not been filled yet.

On a combo box in the form's header I select 'Search Referrer' and press a command button, which opens another form called "frmReferrers". Having selected the referrer, I press a command button, which closes "frmReferrers" and passes the value of the referrer ID to "frmGeneralEnquiries". Here's the code: -

Code:
DoCmd.Close acForm, Screen.ActiveForm.Name
Forms!frmGeneralEnquiries.txtreferralid = intReferrerID
Forms!frmGeneralEnquiries.txtreferralid.Visible = True
DoCmd.GoToRecord acDataForm, "frmGeneralEnquiries", acPrevious
DoCmd.GoToRecord acDataForm, "frmGeneralEnquiries", acNext

The problem I have is that when a record in "frmGeneralEnquiries" is complete and I select a referrer (which is not a mandatory field), there is no problem because it will go to the previous record and then move forward OK which refreshes the referrer ID value. However if the record in "frmGeneralEnquiries" is incomplete in part or whole, I get an error at line

DoCmd.GoToRecord acDataForm, "frmGeneralEnquiries", acPrevious saying can't go to specified record because the mandatory fields are not complete. Is there a another way of refreshing the record in "frmGeneralEnquiries" WITHOUT having to move records?
 
It's hard to tell exactly what you are doing with the given information, but it is certainly not necessary to move away from and then back to a record to refresh it.

First of all, what is it you are trying to refresh? The contents of a combo box? A calculation? A subform?

Depending on your answer, there are several ways to do this:

Me.Requery
Me.Refresh
MyControl.Requery
Me!MySubForm.Requery
Me!MySubForm.Form.Requery
Me!MySubForm.Form.RecordSource = Me!MySubForm.Form.RecordSource

Any one of these commands might do the job, if I just knew what it was you are trying to do.

Evan
 
Actually I missed out the point that the value does appear, but i have a subform set up so that when the value goes on the Caption of a label, when u hover the mouse ove the label, the subform shows the details of the referrer. That doesn't appear. Sorry for not mentioning this earlier.

Hence I will look at your last three options and see if I can get it t work. Looks like it's going to be a busy weekend for me as I work from home.
 

Users who are viewing this thread

Back
Top Bottom