Choose a specific option from combobox. (1 Viewer)

Shankar14

New member
Local time
Today, 06:54
Joined
Apr 6, 2022
Messages
7
Hello, I started using access recently and I am badly in need of help.

There are few data fields in a page and If I mark the first field as 'N/A', I want all the other fields to appear as 'N/A'. I was successful in that attempt of the fields with a "free text" property however, I am unable to get the 'N/A' for fields with a combobox option. The combobox has an option of 'N/A' in the list.

My question is how do I make a specific option appear while writing a IF..Then queries by choosing a specific option from combobox.

TIA.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:54
Joined
Oct 29, 2018
Messages
21,454
Hi. Welcome to AWF!

You'll have to use the value that the combobox is expecting. For most comboboxes, that would be a number.
 

Shankar14

New member
Local time
Today, 06:54
Joined
Apr 6, 2022
Messages
7
Hello,

Thanks for the response. I tried the number even then, I could not work it out.
If "Me.Text380" is written as 'N/A', I want all the other fields to be 'N/A' however "Me.Combo24.Value" is not being marked as N/A.

|I tried to code this as well. " SELECT [tbl2_SiteLkUp].[ID], [tbl2_SiteLkUp].[Site] FROM tbl2_SiteLkUp ORDER BY [Site]; ", no use.

1649327522284.png


1649327251934.png


Kindly help me.
 

Eugene-LS

Registered User.
Local time
Today, 08:54
Joined
Dec 7, 2018
Messages
481
Try:
Code:
Me.Combo24 = DlookUp("ID", "tbl2_SiteLkUp", "ID = 11")
or
Code:
Me.Combo24 = DlookUp("ID", "tbl2_SiteLkUp", "Site = 'N/A'")

My "two cents": Try to name the form objects intelligibly - otherwise you will get confused with them later
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:54
Joined
May 7, 2009
Messages
19,231
it is Unlikely that in the future you will change your tbl2_SiteLkUp table and
assign "N/A" to a different ID.
the reason is that if you do that, all historical record will now point to the wrong
Site. and you need to create an Update query just to update the "old" records.

you can assign it manually (unless the Bound column is not 1):

Private sub text380_afterupdate()
If me.text380 & "" = "N/A" then
Me.Combo24 = 11
End If
End Sub
 

Shankar14

New member
Local time
Today, 06:54
Joined
Apr 6, 2022
Messages
7
I tried those 2 codes.. It didn't work. Can you let me know if I can get any other way
 

Sarah.M

Member
Local time
Today, 08:54
Joined
Oct 28, 2021
Messages
335
Hello, I started using access recently and I am badly in need of help.

There are few data fields in a page and If I mark the first field as 'N/A', I want all the other fields to appear as 'N/A'. I was successful in that attempt of the fields with a "free text" property however, I am unable to get the 'N/A' for fields with a combobox option. The combobox has an option of 'N/A' in the list.

My question is how do I make a specific option appear while writing a IF..Then queries by choosing a specific option from combobox.

TIA.
Try this, click on the link
Create a Combo Box That Allows a User to Select N/A
 

Users who are viewing this thread

Top Bottom