Solved Text box from Combo box (1 Viewer)

Char409

New member
Local time
Today, 07:15
Joined
Jul 12, 2021
Messages
14
So I have a form that fills out a table and I have 4 combo boxes that are based off of each other where as I select a machine it only shows pm's for that machine in the next combo box. Now I want a text box to display the frequency of the pm based on what pm is selected. I tried this in control source for the text box:
=DLookUp("[Frequency]","tblTask","[tblTask].[Maint Work] = " & [Maintwork])

Maintwork is the name of the combo box on the form
when I use this the text box just flashes really fast with #error!
I think I read something that Dlookup has to return a unique value and maybe that is my problem? There could be multiple machines with the same PM just different names and the frequency repeats a lot like "weekly"

I also tried the same setup for my combo boxes which is like: =SELECT DISTINCT tblTask.[Frequency], tblTask.[Maint Work] FROM tblTask WHERE (((tblTask.[Maint Work])=Forms![frmPMfill]![Maintwork]));

But it seems I can't use select distinct for text box control source?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:15
Joined
Oct 29, 2018
Messages
21,358
Hi. If the frequency information is also stored in the PM table, you can simply include the frequency column in the PM combobox row source and display it in an unbound textbox using the Column() property of the Combobox.
 

Char409

New member
Local time
Today, 07:15
Joined
Jul 12, 2021
Messages
14
Well the form's control source is "tblPMentered" so my maintenance tech can fill out what they did and it fills out that table. All the information is stored in a table called "tblTask"
I just wanted the text box to display the frequency because some tasks are very similar like filling oil monthly compared to replacing the oil yearly
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:15
Joined
Oct 29, 2018
Messages
21,358
Well the form's control source is "tblPMentered" so my maintenance tech can fill out what they did and it fills out that table. All the information is stored in a table called "tblTask"
I just wanted the text box to display the frequency because some tasks are very similar like filling oil monthly compared to replacing the oil yearly
I'm sorry, but without being familiar with your database structure, that information is not clear to me. You said you have a combobox showing the PM, correct? If so, if the frequency is tied to that PM, then you should be able to add that information to the same combobox, so it will be available to you already without having to do a DLookup().
 

Char409

New member
Local time
Today, 07:15
Joined
Jul 12, 2021
Messages
14
so i select a machine from combobox machine and its row source is:
SELECT DISTINCT tblTask.[Maint Point], tblTask.Machine FROM tblTask WHERE (((tblTask.Machine)=Forms![frmPMfill]!Machine));

then the next combo box
I have my row source of my combo box set to:
SELECT DISTINCT tblTask.[Maint Point], tblTask.Machine FROM tblTask WHERE (((tblTask.Machine)=Forms![frmPMfill]!Machine));
so it only shows pms for the machine selected in the first combo box

and once the combo boxes have been selected i have a save button which saves the information to a table which the form control source is
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:15
Joined
Oct 29, 2018
Messages
21,358
I have my row source of my combo box set to:
SELECT DISTINCT tblTask.[Maint Point], tblTask.Machine FROM tblTask WHERE (((tblTask.Machine)=Forms![frmPMfill]!Machine));
Again, without being familiar with your database setup, that information doesn't really make sense to me. You said you want to see the "frequency" information. How can you get that data from that row source? Besides, you said you have 4 comboboxes, but you only gave us one row source. What if the frequency information could actually come from one of the other row sources?

You might consider posting a sample db to make this process of us helping you go much quicker.
 

Char409

New member
Local time
Today, 07:15
Joined
Jul 12, 2021
Messages
14
Does this help?
 

Attachments

  • Sample.accdb
    1.4 MB · Views: 449

Users who are viewing this thread

Top Bottom