Solved

put first letter of combobox in a text box

Posted on 2012-04-12
4
300 Views
Last Modified: 2012-04-12
Ok this is going to be hard to explain, but what I am trying to accomplish is putting only the first letter of a combo box into a text box.  For example, if I put Security Cameras in cmbcategory, txtinventory number should start with a "S".  I dont know if this is possible, so if anyone could give me suggestions/solution I would be greatly appreciated.  Thanks in advance!!!
0
Comment
Question by:russell12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:PeteEngineer
ID: 37841106
Let me make sure I understand what you're asking. You have a dropdown based on a query with several fields. When you select an item from the dropdown, you'd like to populate other text boxes on the form with additional information from the dropdown.

Here is how I've accomplished this. Rather than refering to the query behind the dropdown, I simply do a one-time query on the original table. I'm somewhat new at Access, too. (Forced to convert from Visual FoxPro.) There may be a way to do the same thing with the dropdown's query.

This is an Access 2003 example. I don't know if the DAO.recordset type translates to newer or older versions.

For the After Update event on the dropdown add the following code:

Private Sub Dropdown1_AfterUpdate()
    Dim dbTemp As Database
    Dim rsTemp As DAO.Recordset

    'Open connection to current Access database and perform the search
    Set dbTemp = CurrentDb()
    Set rsTemp = dbTemp.OpenRecordset( _
       "SELECT LastName,FirstName FROM Employee_List where " _
       & "EmployeeCode = " & Str(me.Dropdown1.value))

    'Update other fields if data is found
    If rsTemp.EOF = False Then
       me.LastName.value = rsTemp("LastName")
       me.FirstName.value = rsTemp("FirstName")
    Else
       me.LastName.value = ""
       me.FirstName.value = ""
    End If

    rsTemp.Close
    Set rsTemp = Nothing

End Sub

Open in new window

0
 
LVL 8

Expert Comment

by:PeteEngineer
ID: 37841110
Or



Private Sub ComboBox1_Change()

'note:  the default property is .Text

TextBox1 = ComboBox1

End Sub

Open in new window

0
 
LVL 2

Author Comment

by:russell12
ID: 37841115
No not actually, What I am looking for is if I select Security Cameras, my text box will display S automatically.  I have a script, but it isnt working all that well right now.  This might help you understand what I want.  Thanks!!

txtInventory.Value = txtfirstdigitcategory.Value & "-" & Nz(DMax("[Inventory #]", "tblinventory") + 1)
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 37841119
In the Control Source of your textbox put:

=Left(cmbcategory.value,1)

Flyster
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question