Results 1 to 8 of 8
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Change a memo unbound text box when combo box changes

    I have



    an unbound combo box
    an unbound text box (made to resemble a memo field)

    a continuous form with many schooltype

    the form is filtered by schooltype when the unbound combo box is changed i.e. high school, primary etc

    I have made a field in the tblSchoolType called emMessage1 (there is 2, 3 etc)

    the idea is that you choose to filter the form and then the relevant type emMessage1 appears in the text box

    so if you choose high school then the high school emmessage1 appears (filled with the text)

    because all the high schools are tied to tblschooltype - when you select high you are getting the high emmessage1

    When I select all records I am guessing that the text box will be invisible until you select a school type in the combo box (to avoid problems)

    when you have selected a type, the text gets swapped accordingly to the corresponding id of school type id thus changing emMessage1 to suit and make the textbox visible

    now I can type in the field and it saves it in the table however:

    I do not know how to do this.

    I thought about dlookup but not sure if that will allow me to change or whether it will do this

    any suggestions?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What is the RecordSource for the form? Is it tblSchoolType or another table? Do these tables have a relationship? Can tblSchoolType be included in the form RecordSource?

    Textbox can have an expression with DLookup.

    Need to know more about structure of tblSchoolType. There are fields named emMessage1, emMessage2, emMessage3? What criteria determines which record is needed?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    What is the RecordSource for the form? Is it tblSchoolType or another table? Do these tables have a relationship? Can tblSchoolType be included in the form RecordSource?

    Textbox can have an expression with DLookup.

    Need to know more about structure of tblSchoolType. There are fields named emMessage1, emMessage2, emMessage3? What criteria determines which record is needed?
    recordsource for the form has tblSchoolType in it (it's a linked table to tblSchools). Yes related. Yes can be included.

    If it can make the textbox have a dlookup - can I edit what it shows?

    structure is:

    SchoolTypeID SchoolType emMessage1 emMessage2 emMessage3
    1 High Dear Sir To the Lib To the DP

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I have added

    Code:
    =DLookUp("EmMessage1","tblSchoolType","SchoolTypeID=" & [Text38]) 'text38 is the combo box
    I have made clicking in the textbox open to another form that has a box to type (of the same field emMessage1)

    when you swap the combo it changes however

    on null combo box I get #error

    I could make it invisible until you choose a type... unless you have a better suggestion?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    One issue at a time. First you were just populating a textbox, now opening a form? I am confused. If the table is in the form RecordSource, there is no need for DLookup.

    If 'high' should always use emMessage1, why does it have values in the other two fields? Maybe table structure should be like:

    ID Type Message
    1 high Dear Sir
    2 middle To the Lib
    3 elem To the DP
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    One issue at a time. First you were just populating a textbox, now opening a form? I am confused. If the table is in the form RecordSource, there is no need for DLookup.

    If 'high' should always use emMessage1, why does it have values in the other two fields? Maybe table structure should be like:

    ID Type Message
    1 high Dear Sir
    2 middle To the Lib
    3 elem To the DP
    The original table was always without the emMessage1

    Each school had an id number depending on what they were e.g.

    High school is ID 1
    Primary school is ID 2

    and so on

    each type has up to 3 email fields (this I added on recently)

    So if you have chosen to view high schools via a combo box, then automatically it will display the stored email message body for high school category - up to 3 different kinds which I hope to toggle later using an option box and swapping the control source (for the text field that displays the message body on the form)

    so primary, high etc could each have a Dear Sir/Madam however each one could be varied and customized to suit.

    Because I did a dlookup I can't edit it so I made another form that pops up when you enter the displayed text field allowing you to edit what you see in the dlookup.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am still fuzzy on the three fields and when each should be selected, why DLookup is needed if fields are in the RecordSource, and how the tables are related.

    The tblSchoolType offers users some 'canned' email text but you want to allow them to change the text? Where is this changed text saved to?

    VBA code can populate textbox and that will leave it user editable.

    Is the form in continuous view?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ok I managed to get it to work the way I wanted

    I used on the button, several of these:

    Code:
    ElseIf Me.Frame63 = 1 And Me.Command47.Caption = "Blank Emails" Then
    Me.Filter = "[Area] Like '*" & Me.Text36 & "*'" & IIf(Not IsNull(Me.Text38), " and SchoolTypeID=" & Me.Text38, "") & IIf(Not IsNull(Me.txtStates), " and StateID=" & Me.txtStates, "") & "And [1ContactEmail] Is Null"
    Me.FilterOn = True
    Me.Command47.Caption = "Show All"
    ElseIf Me.Frame63 = 1 And Me.Command47.Caption = "Show All" Then
    Me.Filter = "[Area] Like '*" & Me.Text36 & "*'" & IIf(Not IsNull(Me.Text38), " and SchoolTypeID=" & Me.Text38, "") & IIf(Not IsNull(Me.txtStates), " and StateID=" & Me.txtStates, "")
    Me.Command47.Caption = "Blank Emails"
    on the option box I used (several)
    Code:
    Case 1
    Me.txtSchoolEmail.ControlSource = "[1ContactEmail]"
    Me.Label29.Caption = "Contact Email"
    fieldemailchange = "1ContactEmail"
    Me.Label184.Caption = fieldemailchange
    Me.Filter = "[Area] Like '*" & Me.Text36 & "*'" & IIf(Not IsNull(Me.Text38), " and SchoolTypeID=" & Me.Text38, "") & IIf(Not IsNull(Me.txtStates), " and StateID=" & Me.txtStates, "")
    Me.Command47.Caption = "Blank Emails"
    Me.FilterOn = True
    it all works

    thanks for your help guys

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 11-20-2013, 01:03 PM
  2. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  3. Change Text field to Memo Field in a Query
    By Yarbz in forum Queries
    Replies: 5
    Last Post: 06-28-2012, 05:24 PM
  4. Replies: 20
    Last Post: 09-06-2011, 12:39 PM
  5. Replies: 0
    Last Post: 02-24-2009, 12:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums