Combo box to filter form (1 Viewer)

PWG

Registered User.
Local time
Yesterday, 17:44
Joined
Jun 13, 2019
Messages
56
I am working with the northwind database and adding to it for my need.
I have a parts detail form that when opens all the fields are empty. It is set to open to a new record.
There is a combo box in the header that allow you to chose a part number and then all the information is displaced in the detail.
The problem I have is that when you go to chose another part number in the combo box the records will not change.
I think that my problem is in the code on the On Got Focus


Code:
[OnError
       Go to Next
   Macro Name

If [Screen].[activeForm].[Name]=[Form].[Name] Then
     Requery
        Control Name =[Screen].[ActiveControl].[Name]
end if]
 
Last edited by a moderator:

PWG

Registered User.
Local time
Yesterday, 17:44
Joined
Jun 13, 2019
Messages
56
I dont know that much about code but should I be placing my form name in the brackets
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:44
Joined
Jul 9, 2003
Messages
16,271
Not 100% sure that I understand the essence of your question, however I thought this thread might help:- "Northwind Problem and Solution"
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 20:44
Joined
May 21, 2018
Messages
8,524
If [Screen].[activeForm].[Name]=[Form].[Name] Then
Requery
Control Name =[Screen].[ActiveControl].[Name]
end if]

I do not understand what your code is supposed to do, that does not move to a found record. I would expect to see some code in the combos afterupdate that moves to the selected record.

As for naming, most of the time you only have to surround with [] when you have a bad name (spaces, reserved word, or special characters). You do not need [] around methods or properties or events. However, I do not think it actually causes a problem if you include.

so this is required
me.[some control Name].value
this is fine
me.Some_Control_Name.value
so this is fine
Screen.activeform.name


However in an expression you have to use [] and in a query you have to use []
Select * from someTable where SomeField = Forms![FormName]![ctrlName]
or in expression
=[SomeControl1] * [somecontrol2]
 

PWG

Registered User.
Local time
Yesterday, 17:44
Joined
Jun 13, 2019
Messages
56
Just a note to thank you. My problem was the one described in the link. I solved it in another way. I found that the form was getting data directly from the table. I made a separate query and used that fixed the problem.
Again thanks
 

Users who are viewing this thread

Top Bottom