+ Reply to Thread
Results 1 to 2 of 2

Pull excel 2013 DB records into a userform for editing, and re-submitting

Hybrid View

bigfatpies Pull excel 2013 DB records... 01-29-2014, 02:29 PM
mehmetcik Re: Pull excel 2013 DB... 01-29-2014, 04:11 PM
  1. #1
    Registered User
    Join Date
    02-13-2013
    Location
    United Kingdom
    MS-Off Ver
    MS365 MSO Version 2211
    Posts
    18

    Pull excel 2013 DB records into a userform for editing, and re-submitting

    Hello everyone.

    Im very new to VBA but have managed to cobble some fairly decent userforms together for collecting client data selection during an ordering process.
    I was thinking about using a userform to pull in data from the simple excel db records, by maybe selecting an invoice no or customer name...
    I have no clue how to go about this.. so appreciate it will be difficult to solve ... so im really looking for any guidelines/tips that i can go off and research...

    On my userform Id like to have a textbox (lets say ; Job No)...that I can click on and then use arrow keys (not a scrollable list), so that i can flick through the historical records... .. and as the job number changes, all the other record fields would be pulled in instantly so I can quickly scan through them in a nice format,,,,and if I see ne Id like to change... I can simply manually change the data, and when I submit (with cmd button) it would re-write the correct data back to the DB...

    as an example, assume there are just 10 fields per record ..(there are actually 70 or so) : "job No" followed by personal details, address, phone, email etc) so that on my userform (which im happy designing ) I have a listbox or combobox ?? that I can arrow through, and the other fields will be instantly populated... I will later look to expand the functionality so that when the order data is displayed, it references items by looking them up in a pricelist, and showing the order value....

    Is this too generic a question ?? if so I apologize... but dont really know where to start... ill probably be able to pick up the gist of the solution pretty quick if someone can shoot me in the right direction !!!

    Thanks in advance..

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Pull excel 2013 DB records into a userform for editing, and re-submitting

    Hi.

    Forget about the text or combobox for scrolling through your invoices. use a spin button.
    Link that to a textbox that will show your selected invoice
    the spin button value will be the row in your database.

    all your data should be in textboxes so that they are simple to load and save.
    The following is untested but should work.


    READ Data from excel to vba.
    LR = spinbutton1.value
    myarray = range(cells(LR,1),cells(LR,70)).value
    Fill Texboxes
    For Count = 1 To 70
    'Load Text Boxes
    Me.Controls("Textbox" & Count).Text = MyArray(1, Count)
    Next
    Write Texboxes to array
    For Count = 1 To 70
    'Load Text Boxes
    MyArray(1, Count) = Me.Controls("Textbox" & Count).Text
    Next
    Write Data from Array to Excel
     range(cells(LR,1),cells(LR,70)).value = myarray

    To tranfer Spinbutton value to text box.
    You need to declare a variable at the top of your module

    Dim ChangeFlag as integer
    
    private sub spinbutton1_change()
    if changeflag = 1 then exit sub
    Changeflag = 1
    textbox1.value = Spinbutton1.value
    changeflag = 0
    end sub

    To allow direct input into textbox
    private sub Textbox1_change()
    if changeflag = 1 then exit sub
    Changeflag = 1
    Spinbutton1.value = textbox1.value
    changeflag = 0
    end sub
    Last edited by mehmetcik; 01-29-2014 at 04:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. EXCEL 2013 - opening read only files and editing them
    By sca1079 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2014, 09:03 PM
  2. Putting Spreadsheet Into Date Order After Submitting Userform
    By stuu3270 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 08:38 AM
  3. Filter Table when submitting data from a Userform
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2013, 04:46 PM
  4. Change userform texbox value to number after submitting to wks
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-14-2012, 03:52 PM
  5. Losing public variable when submitting userform
    By JP Romano in forum Excel General
    Replies: 2
    Last Post: 01-29-2009, 11:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1