Results 1 to 8 of 8
  1. #1
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138

    Button click

    I have a button that when I press it it goes to new screen where I can add new data in, and then save it.
    I have 10 texboxes in this form, how can I when press the button to add data let it on 3 texboxes show info eg. 4321MAG01- and when I am on the new form I can change or add to it. eg 4321MAG01-123. What vb code can I use

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is 4321MAG01? Is this a static prefix? Or is this value dynamic?
    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
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    4321MAG01- is info that I get from a company, but the number is will always be 4321mag01-000 till 99999 the 000 (depends what number it is) I want to add in, so that I do not have to type the whole number every time. I want 4321MAG01- to show in the textbox when I press the add record(New) button.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Options.

    1. Input Mask

    2. VBA code

    3. If the prefix is always the same then it is repetitive data, don't save it. Save the sequential ID into number field and concatenate the prefix in textbox expression when needed.

    The sequential part of an alpha/numeric identifier should always have the same number of digits, otherwise records will likely not sort properly: 4321mag01-01119 will sort before 4321mag01-012. Is that what you want?
    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.

  5. #5
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    Thank you, I am new to access, so can you please explain more on what you want me to do.

    The 4321MAG01-001 will be for about 5 records and 002 for 1, so it will always change.

    So in my textbox I can always type new info and then save it, so in this texbox I want to show 4321MAG01-

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't understand that second statement.

    You can input a value (1 - 99999 if you like) into a number field.

    Then an expression can be in a query to create a field:

    MyID: "4321MAG01-" & Format([fieldname],"00000")

    Or in a textbox ControlSource property on a report:

    ="4321MAG01-" & Format([fieldname], "00000")
    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.

  7. #7
    hendrikbez is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2014
    Posts
    138
    Ok I got it to work with Set the default value property for the control(s) to "4321MAG00-"

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    That's one way but doesn't prevent user changing the prefix or even completely deleting it. An Input Mask would.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 02-07-2014, 08:37 AM
  2. Click button to open a new image
    By tia in forum Forms
    Replies: 2
    Last Post: 10-10-2011, 11:03 AM
  3. Trying to click a button in vba
    By boywonder in forum Programming
    Replies: 8
    Last Post: 05-02-2011, 04:34 AM
  4. +1 on button click
    By 10 Gauge in forum Forms
    Replies: 4
    Last Post: 02-14-2011, 06:51 AM
  5. Increment a value on button click
    By michaeljohnh in forum Programming
    Replies: 9
    Last Post: 08-25-2010, 10:01 AM

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