+ Reply to Thread
Results 1 to 16 of 16

VBA form design, need help creating form which adds things to database

  1. #1
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    VBA form design, need help creating form which adds things to database

    simple VBA data input form (for someone who knows what they're doing)

    This is the database format that I require.

    database format.png

    I need a form like the following in excel which will contiuously add the data (without overwriting)

    form input.png

    Any help is much appreciated.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA form design, need help creating form which adds things to database

    Upload a template workbook with the headings you want rather than a picture

  3. #3
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA form design, need help creating form which adds things to database

    hi,
    for a start, try to make a test file using this http://www.contextures.com/xlUserForm01.html creating your UserForm as you want and then you can go to the next step, the codde for it!

    *Sorry Kyle, I did not see yr response!
    Last edited by john55; 04-14-2015 at 05:25 AM.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  4. #4
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Hey Guys I really appreciate your responses. As advised please see attached the relevant spreadsheet. Thanks guys
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Any luck on this yet guys? A sample form would be fine. I am just not familiar with the coding. I assume it would be simple if I knew VBA and I used the office for however the layout of the form is just a list of integers which would work however the idea behind it is to add some information which isn't actually typed like "todays date" and "auto assigned number reference"

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA form design, need help creating form which adds things to database

    Did you follow the link posted by John55?

  7. #7
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Hey Guys, did as much as I could myself, could you look at this and tell me where the code is wrong?

    Much appreciated!
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Sorted it guys, Thanks (y)

  9. #9
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Hi guys another question, I want to set up the spread sheet to auto assign job number... Example.

    There has been 1285 entries on the spread sheet. the spread sheet reference numbers I have assigned are numerical starting from 7000

    The last entry was 8285

    When I submit my for I want it to auto assign the job number to be 8286. What code should I add to the command button in order for it to enter the correct reference?

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA form design, need help creating form which adds things to database

    Hi,
    I do not see where the job number is located.
    just to find the first avbl row taking into account data from one column, let's say column A, and increase the number try this
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Ok it only gets more complicated now. I managed a work around for the job number. However after entering the form information and the database obviously starts taking place. I have tabbed a new sheet which I intend on having a display option for the job sheet

    What I have done is recreated the form layout and I want to enter a job number and on the execution of the macro for it to, from the job number given to import all the information from the database onto the form layout.

    I believe the macro should have a "findrow" function where column "B" matches "job number given"

    Then use the row found to get the relevant info ie. date = row D, on ws.serviceDB copy cell (D, "row No") to ws."view job".(F, 4)

    See attached example
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA form design, need help creating form which adds things to database

    if you want to see data from ServiceDB into form you can do it selecting a job number and then goto Viewjob.
    add this piece of code to ServiceDB worksheet selection change. is this what you are looking for?
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    I don't understand how that code works. where do I enter the row I need? and how do i activate the macro which pulls in the relevant information to the search

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA form design, need help creating form which adds things to database

    hi,
    hit Alt F11, the left side->select Sheet1(ServiceDB), the right side, from (General)-> select Worksheet, from (Declarations) select Before Double Click.
    copy/paste the code (without Private Sub... and End Sub lines)

    when you double click in column B, let's say B4, sheet View Job is activated and the form is populated.

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    04-14-2015
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    13

    Re: VBA form design, need help creating form which adds things to database

    Works good, any way you can build this into a job number (type into text box) and use this text box (job number) to search for that inparticular job number and load up the relevant information with a command button (as per the attachment)

  16. #16
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: VBA form design, need help creating form which adds things to database

    hi,
    you can play with these forms:
    add a textbox to yr UserForm and add this piece of code
    Please Login or Register  to view this content.
    add a commandbutton to yr UserForm also (to populate the View job sheet)
    Please Login or Register  to view this content.
    Last edited by john55; 04-22-2015 at 03:03 AM.

+ 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. Creating a Form That keeps Its Properties While Pulling from database
    By joeynice in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2013, 09:24 PM
  2. Creating Database from Input Form
    By geissler05489 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2013, 11:04 AM
  3. Creating Electronic Form Using Design Mode
    By AConneely in forum Excel General
    Replies: 4
    Last Post: 08-16-2012, 06:03 PM
  4. Creating a form to query and update database
    By pizlam in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2010, 02:37 AM
  5. Creating a form for my database
    By Naud in forum Excel General
    Replies: 0
    Last Post: 10-29-2009, 10:23 AM

Tags for this Thread

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