requery a form froma control (1 Viewer)

Bladerunner

Registered User.
Local time
Today, 04:06
Joined
Feb 11, 2013
Messages
1,799
FrmlossRecord
cbolossreason on above form

By using the 'afterupdate' event of cbolossreason, an if/then statement checks to see if the selected item in the cbolossreason is *ADD*.

If it is true, the 'IF'statement opens the FrmLossReason ( which uses the TblLossReason) allowing the user to add a new lossreason on the fly.

After saving the new lossreason and closing the form, the first form [FrmLossRecord.cbolossreason] again gets the focus. However, I need to requery the tbllossreason to reflect the new update in the cbolossreason before the user can select the new loss reason.

Have tried to use the GotFocus for the cbolossreason but it also gets focus in the beginning, thus calling a requery where it is not needed. Is there a better way?


Thanks

Blade
.
 
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:06
Joined
Jan 20, 2009
Messages
12,853
Requery the just combo rather than the whole form.

This can be done from the popup form.
 

Bladerunner

Registered User.
Local time
Today, 04:06
Joined
Feb 11, 2013
Messages
1,799
Requery the just combo rather than the whole form.

This can be done from the popup form.


Thank you Galaxiom for the reply. I will assume that needs to be done from the formclose code be specific as well.

Can I qualify the requery since this form will be called by other forms from time to time. They too will need to be requeried?

Thanks again.

Blade.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:06
Joined
Jan 20, 2009
Messages
12,853
Form_Close would be a good place to run it.

You could pass the calling form's name in the OpenArgs argument of the OpenForm command.

Code:
DoCmd.OpenForm "myform", , , , , , Me.Name

Then you can read this string as the OpenArgs Property of the popup form and send the requery to the appropriate form.

Code:
Forms(Me.OpenArgs).cboname.Requery
 

Bladerunner

Registered User.
Local time
Today, 04:06
Joined
Feb 11, 2013
Messages
1,799
Thanks a bunch, was wondering about that, tried 'Form![FrmLossRecord].[Cbolossreason].Requery' but it would not recognize the frmlossrecord. Will use the other way, it will be better.

Thanks again.

Whats the weather like down under?

Blade
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:06
Joined
Jan 20, 2009
Messages
12,853
Thanks a bunch, was wondering about that, tried 'Form![FrmLossRecord].[Cbolossreason].Requery' but it would not recognize the frmlossrecord.

Would need the "s"

'Forms![FrmLossRecord].[Cbolossreason].Requery'

When passing the name as a string you put it in parentheses.

Whats the weather like down under?
Where I live it is quite hot and very humid. Down south they are still fighting bush fires that have been burning for many days.
 

Users who are viewing this thread

Top Bottom