+ Reply to Thread
Results 1 to 23 of 23

database to userform

  1. #1
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    database to userform

    To preface, I am an extreme excel beginner.

    I created a database to store information in for a survey. I made a userform in VBA and it populates the database no problem. Now, what I want to be able to do is highlight a row in the database and be able to see it back in the userform template. Currently I have to print or take a screenshot of the userform if I want to be able to keep it for future reference (rather than read it from the database), but it would be much easier if it could go back and forth. Does this make sense? Is it possible?

    Thank you for ANY help or suggestions.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: database to userform

    Hi excelkt

    Welcome to the Forum!

    Attached is one way. Double click on any cell in column A. Since you've built UserForms I didn't complete the code example but you'll get the idea.

    Notice the code in Sheet1 Module.

    Let me know of issues.
    Attached Files Attached Files
    John

    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.

  3. #3
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Hi - thank you! The double-click - see the userform part works. Unfortunately, now when I click "run" to enter data with the userform into the database it says "Could not set the value property.Type mismatch"

    Any thoughts?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    We need to see your code
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    I've attached a copy of the database & userform, if that is easier. This is the intial code, as when I tried to follow your suggestions, I couldn't make it work. Sorry! Thank you so much for your help!!
    Attached Files Attached Files
    Last edited by excelkt; 09-01-2011 at 11:43 AM.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    For a start you have a missing Control - ComboBox1

    I've filled ever entry on the form & can't duplicate the error

  7. #7
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    ok ive added the double click to userform code to the sheet and when i double click it pulls up the userform, but the userform is empty. sorry if the problem seems obvious - i am an extreme beginner! i barely understand how ive managed to do what i have already done - mostly just trial and error.
    Last edited by excelkt; 08-28-2011 at 04:24 PM.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: database to userform

    Hi excelkt

    Not sure to whom your question is addressed. If to jaslake then please post your workbook with existing code and with data (sanitized of course).

    That'll help me see what you're trying to do...otherwise I need to reverse engineer your workbook and code to understand what you're trying to do...not willing to do that.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    Add this code to the userform
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    I added the above to the userform and this to the sheet:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Please Login or Register  to view this content.
    Last edited by excelkt; 08-31-2011 at 02:57 PM.

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  14. #14
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Hi John,

    Thank you for your help so far! I just realized today that I have to enter the code into the sheet and the userform, before I had entered only the code into the sheet. So here is what I have
    in sheet
    Please Login or Register  to view this content.
    in userform
    Please Login or Register  to view this content.
    When I double click column A it says ambiguous name detected and highlights Private Sub Userform_Initialize from the userform. I have tried naming it Userform and ClinVisitForm. Sorry if this seems obvious - I hadn't even heard of visual basic until a few months ago and this is my first time using it!!

    Thank you so much!

    K

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: database to userform

    Hi excelkt

    This message
    ambiguous name detected
    would indicate you have more than one Private Sub UserForm_Initialize events in the UserForm. My guess is you have an empty version from before
    Please Login or Register  to view this content.
    and the new version you added
    Please Login or Register  to view this content.
    Eliminate the empty one and try again.

  16. #16
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Sorry - I'm not sure what you want me to do. I have posted my workbook and my code. There is no data in the workbook but the code is there. The userform works - it populates the database but I can't make the database (excel sheet) open to the completed userform. I will post my workbook again in case you had a problem opening it?
    Attached Files Attached Files
    Last edited by excelkt; 09-01-2011 at 04:00 PM. Reason: SOLVED

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: database to userform

    Hi excelkt

    Your workbook does NOT include your current code. Can't trouble shoot your workbook without the current code included.

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: database to userform

    Hi excelkt

    Here's your file back WITH code. Please tell me what it's not doing that you'd expect it to.
    Attached Files Attached Files

  19. #19
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    Have you not tried the code that I posted to load the TextBoxes?

  20. #20
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Yes, sorry I didn't reply to you properly - I just posted at the bottom and I realize how ambiguous that was! I had some problems with the code you had provided me with but the problem is solved now. Thank you so much for your help!

  21. #21
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Ah I'm so sorry! I know I must have frustrated you I just literally don't know anything about excel but you fixed it! THANK YOU SO MUCH.

  22. #22
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: database to userform

    Who fixed it? When you have multiple helpers mention names

  23. #23
    Registered User
    Join Date
    07-14-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: database to userform

    Quote Originally Posted by royUK View Post
    Who fixed it? When you have multiple helpers mention names
    jaslake did - thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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