Combo Box to Change Preset Textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • martin DH
    New Member
    • Feb 2007
    • 114

    Combo Box to Change Preset Textbox

    Hello,

    I have a unique situation, I believe. I have a form with unbound textboxes (frmEditReport) - most populate from a search query but one unbound textbox, txt_ReturnInfo, populates based on a selection the user chooses when logging in (code below). Basically, the user selects their office at login and the textbox will populate with the appropriate return mailing address when frmEditReport opens.

    I think this is most efficient since the user will generally login in the morning but reopen this form several times throughout the day.

    My situation is that I also want to provide the ability to change the return address from within frmEditReport. I added a combobox (cboOffice) that listed the three possible locations. Is there a simple way to let the selection in that combo box override the text that is already in txt_ReturnInfo?

    Thanks for any ideas!
    [CODE=vb]Private Sub returnDefault(r eturnType)
    'Set default value for return address section depending on the office selected by the user at login or as selected on screen (bmc 02/13/08)
    Dim crQ As String
    Dim crL As String
    crQ = Chr$(34)
    crL = vbNewLine

    'If Me.cboOffice.Vi sible = True Then
    'txt_ReturnInfo .Value = ? Needs to return the correct office address.

    'Else
    If Forms![frmMainmenu]!txtOffice = "Cincinnati " Then
    txt_ReturnInfo. Value = "company name" & crL _
    & "address1" & crL _
    & "city1, state1, zip1" & crL _
    & "website"
    ElseIf Forms![frmMainmenu]!txtOffice = "Cleveland" Then
    txt_ReturnInfo. Value = "company name" & crL _
    & "address2" & crL _
    & "city2, state2, zip2" & crL _
    & "website"
    ElseIf Forms![frmMainmenu]!txtOffice = "Columbus" Then
    txt_ReturnInfo. Value = "company name" & crL _
    & "address3" & crL _
    & "city3, state3, zip3" & crL _
    & "website"
    Else
    txt_ReturnInfo. Value = ""
    End If
    'End If
    End Sub[/CODE]
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Hi
    I started to write on this a while ago then 'lost' what I wrote so hope this is not coming through twice.

    The bottom line is that you seem to be setting some address data via hard-coding then hoping to change it via the form which is using the hard coding.

    Can't be done! That's what tables are for.

    Put your address details in a small table then bind you form to that table or look-up then paint the screen or whatever.

    I see you have a hundred or so posts so must have a bit of a clue how to do this? Let's know if you get stuck.

    S7

    Comment

    Working...