+ Reply to Thread
Results 1 to 12 of 12

Help with entering data in textbox & checkbox for database

  1. #1
    Registered User
    Join Date
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Help with entering data in textbox & checkbox for database

    I'm new to creating databases using excel and have been asked to continue work on one that has been started by someone else with some knowledge of this.

    User input screen has been created and some coding has been done. I understand the coding which is attached to the "enter hours" button, which is used to enter the user input into the database.

    I need help with the following:
    1) how to allow user to input information into text box and checkbox
    2) how to ensure only numeric input is allowed in textbox

    I have very little knowledge of VBA but have been reading online forums and help files to learn what I can. Any help would be greatly appreciated.

    Attached is a copy of the file. Thank you.
    Attached Files Attached Files
    Last edited by RossKennedy; 09-30-2011 at 12:29 PM. Reason: To mark as solved

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Help with entering data in textbox & checkbox for database

    Not sure why you are using text boxes, could you not use the cells?

  3. #3
    Registered User
    Join Date
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help with entering data in textbox & checkbox for database

    I could, but did not know if getting rid of the text boxes would affect the code, since I have very little knowledge of VBA, I didn't want to change anything in the screen setup.

    After changing these text boxes I find the code does not work. Will I now have to go back and create labels for each item and make sure it has the same name as in the code. ie.

    Please Login or Register  to view this content.
    Do I need to create a label on the input screen named "payperiod" and another for payperiodday and DSHour etc for each variable in the code?
    Last edited by RossKennedy; 09-27-2011 at 09:57 AM. Reason: Edited to correctly add Code tags as per forum rules.

  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: Help with entering data in textbox & checkbox for database

    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
    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
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help with entering data in textbox & checkbox for database

    Quote Originally Posted by royUK View Post
    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
    My appologies, I have now corrected this issue. I thought that by placing the code inside the words "Code" and "End Code" I was adhering to the forum rules. Thanks for pointing out my error.
    Ross Kennedy

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Help with entering data in textbox & checkbox for database

    It seems like a lot of work placing textboxes over a cell, especially when it is not required.
    Why not use a cell value instead of a textbox value?

  7. #7
    Registered User
    Join Date
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help with entering data in textbox & checkbox for database

    Quote Originally Posted by davesexcel View Post
    It seems like a lot of work placing textboxes over a cell, especially when it is not required.
    Why not use a cell value instead of a textbox value?
    By this do you mean that I should have an absolute cell reference in the code? something like the following:
    Please Login or Register  to view this content.
    instead of what I currently have?

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

    Re: Help with entering data in textbox & checkbox for database

    As Dave says, don't bother with the TextBoxes just use the cells. Your code will not find an empty TextBox it's looking at cells & looping to find an empty cell is inefficient
    Last edited by royUK; 09-29-2011 at 01:57 PM.

  9. #9
    Registered User
    Join Date
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help with entering data in textbox & checkbox for database

    Quote Originally Posted by royUK View Post
    As Dave says, don't bother with the TextBoxes just use the cells. Your code will not find an empty TextBox it's looking at cells & looping to find an empty cell is inefficient
    Ok, if I am understanding you correctly, the code I currently have is looking for an empty textbox to place the userinput into.

    This is not what I want the code to do, all I am looking for is for the code to take the input from sheet1 (from cells, not textboxes) and place these said values into a row in sheet2, but it must first check sheet2 to make sure it is starting in an empty cell so that it does not overwrite previous entries in sheet2 (which is where I want my info stored, like a database)

    please note: I did not write the code but have been trying to play with it to get it to work. The code was started by someone else and I have little to no knowledge of vba coding. Trying to learn the basics to make this work

    Thanks for your help

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

    Re: Help with entering data in textbox & checkbox for database

    From the example that youhave attached

    1. Data Entry is into textBoxes not cells
    2.The code that you posted needs a Named Range called Records, this does not exist

    You would greatly simplify this if you forgot about using textBoxes & used the cells themselves. Also, delete all the existing code.

    Then this code is all you need,obviously expand it to include all entries & check the input is in the correct columns

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-26-2011
    Location
    Halifax, Nova Scotia
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Help with entering data in textbox & checkbox for database

    Thank you for your help, I have added some comments to the code you provided. Could you please check my comments to make sure I am understanding exactly what the code does.

    One more question, how do I mark this post as "Solved" , thanks

    Please Login or Register  to view this content.
    Last edited by RossKennedy; 09-30-2011 at 10:03 AM. Reason: added question

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

    Re: Help with entering data in textbox & checkbox for database

    Finding the next empty row in the code is achieved by taking the last row in the column & moving up to the last used cell, equivalent to Ctrl+Shift+ Up Arrow. Then it gets the Row number & adds 1.

    Enters data using Cells(Row Number, Column Number), in this case Row Number is the Variable NextRw

+ 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