how to refresh combo box in subform?

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

how to refresh combo box in subform?

Post by siamandm »

Hi all
i have a subfrom inside a main form which has a combo box called cboDonner,
the cboDonner List Items Edit Form= frmDonner

inside the frmDonner i have a button called btnClose

Code: Select all

Private Sub close_Click()
  DoCmd.RunCommand acCmdSaveRecord
 
    Dim cboDonner As Control
 
    ' Return Control object pointing to a combo box.
    Set cboDonner= Forms!subfrm!cboDonner
 
    ' Requery source of data for list box.
    cboDonner.Requery
 
  
 DoCmd.close
 
End Sub
this code is working for the main form ... but for the sub form i get issue

how to make it work : in summary i want when i click the close button, set focus on the cbo and refresh the data


regards

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: how to refresh combo box in subform?

Post by HansV »

You have to refer to a subform through the main form:

Code: Select all

    Set cboDonner = Forms!mainform!subfrm!cboDonner
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1227
Joined: 01 May 2016, 09:58

Re: how to refresh combo box in subform?

Post by siamandm »

thanks alot ,,, its working now