Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8

    Concatenate field in form resets field focus to field 1

    I have a form that has a field that concatenates three fields together Genus, species and OtherNameValue. As i type in field 1 (Genus) all is well, when I tab to Field 2 to enter (Species) the focus keeps on reverting back to field 1 often mid way through typing in field 2. The same happens in field 3. The concatenated field updates each time it is tabbed. How do I stop the field resetting back to field 1. I feel that the concatenated field is resetting the focus back to field 1?

    Any help would be greatly appreciated.


    Regards
    Stephen

  2. #2
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    It sounds like your using the onchange action of the text box, check the settings for the fields. try after update (when your text entry is completed).
    try a button to create the final text result.

    Or

    Post a sample of your code so we can see what your doing. (save as mdb format, and we can all see it.)

  3. #3
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Hi Trevor,

    Thankyou for your reply. The database is to large to send. I checked the settings for the fields they all look normal. With the AfterUpdate, what would you suggest?
    Regards
    Stephen

  4. #4
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Attachment 15771
    Hi Trevor,

    Attached is a snapshot of the fields.
    Regards
    Stephen

  5. #5
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Unfortunately that attachment is not working. I'll report the failed link for you.


    Attached is a snapshot of the fields, I would also need to see the code you use to do this. VBA or Macro. Copy and paste, or screen image (change any private details) IE "Joe Blow P/L" to "zzz P/L" keeps it clear and safe.

  6. #6
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Click image for larger version. 

Name:	Access.jpg 
Views:	17 
Size:	90.5 KB 
ID:	15772
    Snapshot

  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,902
    The first attachment worked for me.

    Did you run Compact & Repair on db? Did you zip it? Still too large? Can upload to fileshare site such as Box.com and post link to the file.

    Why are you concatenating these fields during data entry?

    Why not just an expression in textbox?
    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
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Hi June7,
    The 3 fields are concatenated to form the full Botanical Name and are highlighted at the the top of the form. How can I concatenate the fields after I have entered all 3 fields?

    Regards
    Stephen

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Expression can be in:

    textbox

    =[Genus] & " " & [species] & " " & [OtherNameValue]

    or query

    FullBotanical: [Genus] & " " & [species] & " " & [OtherNameValue]

    or in VBA (trick is figuring out the correct event but if not saving to a field don't need VBA)

    Me.Genus & " " & Me.species & " " & Me.OtherNameValue
    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.

  10. #10
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Hi June7,

    Yes I have used that exact concatenation string in the textbox. The problem is that as i tab to the species field and start to type the focus converts back to Genus field as the concatenation field updates.

    Regards
    Stephen

  11. #11
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Try this with VBA starts with the first text box only available, afterentering data there it moves to the next text box and disables the first, and so on. you'll have to write the vba code to do this. see how you go, I don't have time right now to do this in a db and post that.

    Form open, disable Spicies, NameOtherValue

    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false

    Enter data in Genus

    me.Genus.afterupdate

    me.Species.enabled = true
    me.Genus.enabled = false
    docmd.gotocontrol "Species"

    Enter data in Species

    me.Species.afterupdate

    me.NameOtherValue.enabled = true
    me.Species.enabled = false
    docmd.gotocontrol "NameOtherValue"

    Enter data in NameOtherValue

    me.NameOtherValue.afterupdate

    me.Your_Result = [Genus] & " " & [Spicies] & " " & [NameOtherValue]
    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false
    me.Genus.enabled = true
    docmd.gotocontrol "Genus" ' back to the start

  12. #12
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    P.S. all 3 text boxes are unbound, the result could be bound to a table field.

  13. #13
    StephenB is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    8
    Hi Trevor,

    All three text boxes are bound to a table

    Do I just paste this at the bottom of the other VB for that form?
    Regards
    Stephen

  14. #14
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Bold text = form/control event, when you click on the event create a vba [Event Procedure], or click on the elipses and select code.
    copy the non bold text into each objects code area. It wont work if you just copy it into the forms code. Each text box needs to be set to have a procedure. P.S. It's not tested so post back if you have problems.

    Private Sub Form_Open(Cancel As Integer)
    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false
    End Sub

    Private Sub Genus_AfterUpdate()
    me.Species.enabled = true
    me.Genus.enabled = false
    docmd.gotocontrol "Species"
    End Sub

    Private Sub Species_AfterUpdate()
    me.NameOtherValue.enabled = true
    me.Species.enabled = false
    docmd.gotocontrol "NameOtherValue"
    End Sub

    Private Sub NameOtherValue_AfterUpdate()
    me.Your_Result = [Genus] & " " & [Spicies] & " " & [NameOtherValue]
    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false
    me.Genus.enabled = true
    docmd.gotocontrol "Genus" ' back to the start
    End Sub



  15. #15
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    Not seeing my post so i'll try again.
    Each control must have code placed into it, large text = were to place code for fields.
    create procedures in those areas and copy each bit of code to the appropriate place. You can't copy the code into the form vba, each field must be selected to have a procedure then copy the code.

    E.G. When the form opens
    Private Sub Form_Open(Cancel As Integer)
    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false
    End Sub

    And so on for the rest of the fields...

    'me.Genus afterupdate code
    me.Species.enabled = true
    me.Genus.enabled = false
    docmd.gotocontrol "Species"

    'me.Species afterupdate code
    me.NameOtherValue.enabled = true
    me.Species.enabled = false
    docmd.gotocontrol "NameOtherValue"

    'Me.NameOtherValue afterupdate code
    me.Your_Result = [Genus] & " " & [Spicies] & " " & [NameOtherValue]
    me.Spicies.enabled = false
    me.NameOtherValue.enabled = false
    me.Genus.enabled = true
    docmd.gotocontrol "Genus" ' back to the start

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-27-2013, 02:33 PM
  2. Concatenate a field to appear on a form
    By snowboarder234 in forum Forms
    Replies: 9
    Last Post: 06-05-2013, 02:01 PM
  3. Replies: 7
    Last Post: 12-22-2012, 06:31 PM
  4. Replies: 1
    Last Post: 11-01-2011, 05:55 PM
  5. HELP! Set Focus to Continuous Sub Form Field
    By asmith78 in forum Programming
    Replies: 1
    Last Post: 09-09-2011, 02:27 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