Refresh issues in cbo of Forms (1 Viewer)

AnilBagga

Member
Local time
Today, 20:02
Joined
Apr 9, 2020
Messages
223
I have an issue with refresh data in the main form/Subform section. The database is huge and in split form (FE and BE) hence sharing screenshots and not DB

1. The form in question is of Invoice entry - Main form and sub form. The issue pertains to the main form

2. I capture the consignee code in the main form from thru a cbo box where source data is from a query built for the Pending orders. Therefore codes which have pending orders are ONLY displayed

3. There is table where we have information of consignee code and container no. We need to capture container no in a cbo box using the information from the container table. Validation is that the consignee code should be same as selected in the form and the container no should be in transit (to limit the items in the cbo)

4. The validation of the container no cbo works when form is opened. However while the Invoice form is open and we change values in the container table, the cbo values are not refreshed! If I close the invoice form and reopen, the cbo values are refreshed!

5. If I use Refresh all from ribbon, command shifts to record no 1 which is not convenient!

What do I do?
 

Attachments

  • Screenshots.zip
    216.4 KB · Views: 132

onur_can

Active member
Local time
Today, 07:32
Joined
Oct 4, 2015
Messages
180
When you enter data into cbo, you should use the code
cboName.Requery to query it. Likewise, when you open another form on an open form, you can update the cbo in the open form when the form you opened later is closed.
You must use the command
Code:
Forms!FormName!CboName.Requery
 

AnilBagga

Member
Local time
Today, 20:02
Joined
Apr 9, 2020
Messages
223
When you enter data into cbo, you should use the code
cboName.Requery to query it. Likewise, when you open another form on an open form, you can update the cbo in the open form when the form you opened later is closed.
You must use the command
Code:
Forms!FormName!CboName.Requery

I use requery on cbo names.

The cbo name is "cboContainerNo" and the form name is "InvHdrfrm2". In this form, the row source for ContainerNo is "tblContainerBooking" and field name is ContaineNo, which is updated by 'frmContainerBooking'. T

The QBE of cboContainerNo is as below

1599356605580.png


The issue I face is as below

1. With Invhdrfrm2 open, I open frmContainerBooking and update fields ContainerNo and ActArrivalDate. These are text and date fields respectively.
2. When I go back to InvHdrfrm2, the values in the cboContainerNo are not updated. The ContainerNo added in frmContainerBooking will not show nor will the criteria filter out the Containerno if ActArrivalDate is entered.

I added 2 requery statements s below in the frmContainerBooking based on yr post

Private Sub ContainerNo_AfterUpdate()
[Forms]![Invhdrfrm2]![cboContainerNo].Requery
End Sub

Private Sub ActArrivalDate_AfterUpdate()
[Forms]![Invhdrfrm2]![cboContainerNo].Requery
End Sub

Does not help!!
 

GinaWhipp

AWF VIP
Local time
Today, 10:32
Joined
Jun 21, 2011
Messages
5,901
Hmm, try putting...

Me.cboContainerNo.Reuery in the On_Click event of cboContainerNo.
 

AnilBagga

Member
Local time
Today, 20:02
Joined
Apr 9, 2020
Messages
223
Hmm, try putting...

Me.cboContainerNo.Reuery in the On_Click event of cboContainerNo.
Requery itself?
Does not fetch any data - blank!

I have another problem

The source data of the cbo consigneecode is a qry. If I try to change the code i get an error as per C1 enclsoed and on debugging get an error as per C2 enclsoed!
 

Attachments

  • C2.JPG
    C2.JPG
    31.3 KB · Views: 309
  • C1.JPG
    C1.JPG
    22.8 KB · Views: 310
Last edited:

GinaWhipp

AWF VIP
Local time
Today, 10:32
Joined
Jun 21, 2011
Messages
5,901
Yes, requery itself and since you are doing so you cannot put the Form name there. You need to put exactly what I put in the On_Click event. If that works then it's probably not doing from the Main Form because data not saved yet.

If that is not working please post the Row Source of the combo box. Not the query name but the SQL. As it might be something about that that is causing the issue.
 

AnilBagga

Member
Local time
Today, 20:02
Joined
Apr 9, 2020
Messages
223
Yes, requery itself and since you are doing so you cannot put the Form name there. You need to put exactly what I put in the On_Click event. If that works then it's probably not doing from the Main Form because data not saved yet.

If that is not working please post the Row Source of the combo box. Not the query name but the SQL. As it might be something about that that is causing the issue.
This is out of my depth

Will try to post the DB with abridged data. Would appreciate if you could help me with the changes. I have started learning access only 4 months ago
 

GinaWhipp

AWF VIP
Local time
Today, 10:32
Joined
Jun 21, 2011
Messages
5,901
Oh okay. Perhaps you could start with posting your Relationships diagram.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:32
Joined
Sep 21, 2011
Messages
14,053
You have [form] not [forms] ???
 

AnilBagga

Member
Local time
Today, 20:02
Joined
Apr 9, 2020
Messages
223
@Gasman- thanks. corrected
@GinaWhipp- DB enclosed. I have tried some other things like me.requery - does not help

Forms in question
InvHDrfrm2 and frmcontainerbooking
 

Attachments

  • MIS_fe - Copy.zip
    372.1 KB · Views: 309

onur_can

Active member
Local time
Today, 07:32
Joined
Oct 4, 2015
Messages
180
The line marked with yellow tape will have an exclamation mark after the form name, not a period.
 

GinaWhipp

AWF VIP
Local time
Today, 10:32
Joined
Jun 21, 2011
Messages
5,901
Well, not sure what you are even doing. Both of these take up the entire screen so how can it query a Form not open? If you are clipping back and forth then once you enter the Container No the record may not be committed (save) to get the value for it to be re-queried. May you can help us out by provided *exactly* what you are doing step-by-step to enter data.
 

Users who are viewing this thread

Top Bottom