Populating textbox based on specific Combobox entry

BriggsyB

New member
Local time
Today, 03:26
Joined
Sep 5, 2019
Messages
5
Hi there,

I have a document management database that I'm working on and was wondering if anyone could please help with an issue I can't seem to overcome?? :banghead:


I have a combo box (Combo309) which lets the user select the document type e.g. form, plan, procedure etc)

I also have a textbox (Document Reference) which records the specific document reference.

Here's where I struggling.........

I would like it so that when "BLUE FOLDER" is selected in Combo309 the document Reference textbox also reads BLUE FOLDER AND is locked.

Could anybody please help????

Many thanks,
 
Hi. Welcome to AWF! Have you tried using the combo’s AfterUpdate event? For example,
Code:
If Me.Combo309="BLUE FOLDER" Then
...
Else
...
End If
 
Thanks for the welcome and to the both of you for your replies, however I don't think that I was clear enough in my original post.

I only want the textbox to display "BLUE FOLDER" when the combobox has BLUE FOLDER selected.

When any other type of document is selected in the combobox I'd like to be able to put the specific document reference number in the textbox

I've gone around the houses with this one.
 
on AfterUpdate event of the combo, add this code:
Code:
Private Sub Combo309_AfterUpdate()
If Me.Combo309="BLUE FOLDER" Then
    Me.txtDocReference = "BLUE FOLDER"
    Me.txtDocReference.Enabled = False
Else
    If Me.txtDocReference = "BLUE FOLDER" Then _
    Me.txtDocReference = ""
    Me.txtDocReference.Enabled = True
End If
End Sub
 
on AfterUpdate event of the combo, add this code:
Code:
Private Sub Combo309_AfterUpdate()
If Me.Combo309="BLUE FOLDER" Then
    Me.txtDocReference = "BLUE FOLDER"
    Me.txtDocReference.Enabled = False
Else
    If Me.txtDocReference = "BLUE FOLDER" Then _
    Me.txtDocReference = ""
    Me.txtDocReference.Enabled = True
End If
End Sub


Thanks for the code arnelgp, I've attached a screenshot of my findings. It still won't work unfortunately :confused::confused::confused:
 

Attachments

  • Combo309.jpg
    Combo309.jpg
    55.5 KB · Views: 67
you have space there?
 
Thanks for the welcome and to the both of you for your replies, however I don't think that I was clear enough in my original post.

I only want the textbox to display "BLUE FOLDER" when the combobox has BLUE FOLDER selected.

When any other type of document is selected in the combobox I'd like to be able to put the specific document reference number in the textbox

I've gone around the houses with this one.
Hi. That's where the ... in my sample code was for. I'm sure Arnel will get you squared away. Cheers!
 
you have space there?

Hi Arnel, yep removed the space, my apologies.

I do not get an error code now when selecting from the Combobox, however I get do not get the desired outcome in my text box.

I am still free to edit the DocReference text box and BLUE FOLDER isn't displayed in the textbox when chosen in the combobox

Thanks again for your help so far.
 

Attachments

  • Combo309.jpg
    Combo309.jpg
    37.3 KB · Views: 69
how many columns does you combo have?
if there are more you can try using Column(1) or another column that has the "BLUE FOLDER":
Code:
Private Sub Combo309_AfterUpdate()
If Me.Combo309.Column(1)="BLUE FOLDER" Then
    Me.txtDocReference = "BLUE FOLDER"
    Me.txtDocReference.Enabled = False
Else
    If Me.txtDocReference = "BLUE FOLDER" Then _
    Me.txtDocReference = ""
    Me.txtDocReference.Enabled = True
End If
End Sub
 
how many columns does you combo have?
if there are more you can try using Column(1) or another column that has the "BLUE FOLDER":
Code:
Private Sub Combo309_AfterUpdate()
If Me.Combo309.Column(1)="BLUE FOLDER" Then
    Me.txtDocReference = "BLUE FOLDER"
    Me.txtDocReference.Enabled = False
Else
    If Me.txtDocReference = "BLUE FOLDER" Then _
    Me.txtDocReference = ""
    Me.txtDocReference.Enabled = True
End If
End Sub

You Hero! making progress, the combo had 2 columns (ID Number & Short Text) I removed the ID number column and changed the column count to 1.

Textbox now displays BLUE FOLDER when the combobox has BLUE FOLDER selected. Just what I wanted.

However, I can still edit the text when it reads Blue Folder. Is there a way of locking the textbox when BLUE FOLDER is displayed, but unlock the textbox when any other DocReference is selected in the combobox??
 
should be disabled when it changes to BLUE FOLDER.
 

Users who are viewing this thread

Back
Top Bottom