Results 1 to 4 of 4
  1. #1
    LedZep2147 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Location
    Philadelphia, PA
    Posts
    2

    Sending string variable to table from form (vba)

    I'm trying to create a form that is used to enter purchase orders into an Access 2003 database.

    Traditionally I would set them up using the wizard, and use the basic objects from the toolbar corresponding to the fields in my table.

    But I wanted to update the way a field is entered. I have a combo box that has 3 choices for a prefix (25,45,95), then the user types in a text box to enter a 8 digit number.

    When the user leaves the text field, the prefix and the number entered into the text box are combined using a global string variable.



    The trouble I'm having is coding the 'add record' button to transfer the variable into my table.

    The pseudo code would be:

    [Add button clicked event...
    (string variable), and All other fields in form to corresponding fields in table-(string variable) to specific field in table]

    Thanks!

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    You didn't use the wizard because you wanted to

    provide the combobox and a textbox to feed a field. That suggests that you didn't bind that field to the table????
    I would have the combobox click look at the textbox and if you had both values, stuff the info into the field. Conversely, if you had a value for the combobox and the textbox was updated, you could feed the field. Then, if the field was bound to the table, the add record button should add the record to the table.
    BTW, you might make the special field not visible so the users have to rely on the combo and textbox.

  3. #3
    LedZep2147 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Location
    Philadelphia, PA
    Posts
    2
    That suggests that you didn't bind that field to the table????
    All of the fields in my form are bound to a table with the exception of one field. The field that is not bound, I want to use a variable from my code to fill the field in my table.

    Just want to know the function (or code) I should use to move the string variable from my code, over to a field in my table.

    Thanks again!

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I didn't state my question properly. Does your form have the table as

    its recordsource? Are there controls on the form which have each of the fields in the table as the control source?
    If that is the case, all you need to do to insert the string into the table is to copy it to the appropriate control, i.e. [SpecialField] = constructedString
    However, I don't think the update will actually occur until the focus leaves the record, i.e. by going to a control not associated with the record. This might necessitate your forcing the user to use the combobox & textbox first? I need to look at that.
    This shouldn't be hard.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-03-2011, 07:41 AM
  2. Replies: 3
    Last Post: 11-03-2010, 09:53 AM
  3. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  4. Automate sending SMS form MS Access
    By Johan in forum Programming
    Replies: 8
    Last Post: 04-15-2010, 12:51 AM
  5. Using a string variable to specify a control
    By Gerry in forum Programming
    Replies: 3
    Last Post: 04-14-2010, 02:28 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