Solved Combo box drops first record when form inside Navigation form (1 Viewer)

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
I have two forms working perfectly when I open them directly, but when I use them inside a navigation form I have the following problem -
A combo box allows me to choose a customer (or employee in the second form), all works fine, BUT after selecting a new customer I cannot use the combo box to choose the first record again. All other records are present and I can move between them but record 1 does not show.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
Are you modifying the Row Source of the combo in any way?
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
The row source criteria is <>Nz([Form]![CustomerID],0). This remains the same whether the form is viewed inside the Navigation Form or by itself.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
The row source criteria is <>Nz([Form]![CustomerID],0). This remains the same whether the form is viewed inside the Navigation Form or by itself.
What happens if you change that to <> Nz([CustomerID],0)?
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Just tried that. The combo box has no records at all.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:54
Joined
Feb 19, 2013
Messages
16,607
Perhaps customer Id is text and not a number in which case it would be <>””
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:54
Joined
Feb 19, 2013
Messages
16,607
Also is your rowsource a query? Or sql?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:54
Joined
Feb 19, 2013
Messages
16,607
And next comment is to try using code to requery the combo. No info on your form so can only suggest use the form current event
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Thought it might help if you saw a picture of what I am doing. You see the combo box has 8 records showing, including the current record. Record no. 1 is not in the list but it should be. If I open the same form independently from the Navigation form I still only get 8 records BUT unlike when in the Navigation form the current record (Sarah Smith) is not listed and record 1 is available to choose. This is how it should be. Note this is the same form, it is not two different forms. The only difference is it doesn't behave properly when it is inside the Navigation form.
ResponsePortal.jpg
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Can you please post the SQL statement of that query? Thank you.
SELECT CustomersExtended.CustomerID, CustomersExtended.CustomerName FROM CustomersExtended WHERE (((CustomersExtended.CustomerID)<>Nz([Form]![CustomerID],0))) ORDER BY CustomersExtended.CustomerName;
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
<>Nz([Form]![CustomerID],0)
Hi. Thank you! I just wanted to verify the above portion. I don't remember using the syntax before. Normally, I wouldn't have the [Form] part. That's why I suggested to remove it earlier. Now, it makes more sense why you didn't get any results when you do that. This is how I would normally do it.
Code:
<> Nz(Forms!FormName.CustomerID,0)
Could you please try that and verify that it returns the same items in the dropdown? Please remember to replace "FormName" with the actual name of your form.

If it works, then to use your form in a Navigation Form, you will have to change the above to something like this:
Code:
<> Nz(Forms!NavigationForm.NavigationSubform.Form!CustomerID,0)
Again, you will have to use the actual names of your Navigation Form and the Subform container on the Navigation Form.

Hope that helps...
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Hi. Thank you! I just wanted to verify the above portion. I don't remember using the syntax before. Normally, I wouldn't have the [Form] part. That's why I suggested to remove it earlier. Now, it makes more sense why you didn't get any results when you do that. This is how I would normally do it.
Code:
<> Nz(Forms!FormName.CustomerID,0)
Could you please try that and verify that it returns the same items in the dropdown? Please remember to replace "FormName" with the actual name of your form.

If it works, then to use your form in a Navigation Form, you will have to change the above to something like this:
Code:
<> Nz(Forms!NavigationForm.NavigationSubform.Form!CustomerID,0)
Again, you will have to use the actual names of your Navigation Form and the Subform container on the Navigation Form.

Hope that helps...
Worked fine by itself using your first example but when I modified it and ran it inside the Navigation form I got the following error.
Error.jpg
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
Worked fine by itself using your first example but when I modified it and ran it inside the Navigation form I got the following error.
View attachment 91932
Yeah, that part is a little tricky. You need to make sure you use the name of the subform container, rather than the name of the form it contains. If you used the Wizard to create the Navigation Form, that name is usually assigned as Navigation Subform. If so, it sounds like CustmerDetails is the name of the form it contains.
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Yeah, that part is a little tricky. You need to make sure you use the name of the subform container, rather than the name of the form it contains. If you used the Wizard to create the Navigation Form, that name is usually assigned as Navigation Subform. If so, it sounds like CustmerDetails is the name of the form it contains.
That makes sense. I changed the form name to NavigationSubform and it runs, but no differently to the original issue. I still can't get that first record. It seems to me the SQL query is fine either way so it's got to be somewhere else interfering with the result.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
That makes sense. I changed the form name to NavigationSubform and it runs, but no differently to the original issue. I still can't get that first record. It seems to me the SQL query is fine either way so it's got to be somewhere else interfering with the result.
That may be, and we can't really help if we can't see it in action. Are you able to post a demo version?
 

Goochie

New member
Local time
Today, 13:54
Joined
May 27, 2021
Messages
14
Here you go. ResponsePortal is the Navigation form. Customers and Employees contain the combo boxes with the problem.
 

Attachments

  • demo.accdb
    5.6 MB · Views: 286

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:54
Joined
Oct 29, 2018
Messages
21,467
Here you go. ResponsePortal is the Navigation form. Customers and Employees contain the combo boxes with the problem.
Hi. Thanks! Please take a look now...
 

Attachments

  • demo.zip
    749.5 KB · Views: 264

Users who are viewing this thread

Top Bottom