PDA

View Full Version : Generate number when userform information is submitted



Hanret
08-25-2013, 07:36 PM
I am new member on this site and pretty new to VBA.

I have created a MultiPage UserForm to enter a client's personal information for transfer to a Data Base. I am using 2 separate workbooks to do this - one that houses the UserForm and one that houses the Data Base. I am successfully managing to get the information entered on the UserForm to go to the Data Base.

But, I need two operations to follow when the CommandButton 'Submit' is clicked:
1) On Submit, in the first column allocate a unique number or ID to the client whose information is being submitted
2) On Submit, calculate the client's age based on the Date of Birth field entered on the UserForm

Am looking forward to your advise.

Thanks

Hanret
08-26-2013, 06:08 AM
Apologies, it has been pointed out to me that I have been cross-posting as I indeed have, and how uncool that is.

I have managed a work around to allocate a unique number for each time a client's information is capture. Not sure that it is the best way to do this, but for now it works. I posted the work around on the Excel Forum site. Unfortunately this post is not allowing me to link to the site.

Apologies again.

SamT
08-26-2013, 06:45 AM
Hanret, The FAQ link at the top includes Forum etiquette rules. I think you can add a link after two posts.

If the client ID number is in sequential order just retrieve the Max(ID_Column) value and add 1.

Age can be calculated by merely subtracting DOB from Now. For information on dates, Type "Date" in the VBA Editor, (VBE,) leave the cursor inside the word and press F1. In the help page that comes up, click the "See Also" link at the top. Also do this for NumberFormat.

For more specific help from us, we'll need more specific information from you, such as, how the DOB is entered on the Form, and a sample of the Database Sheet.

Kenneth Hobs
08-26-2013, 07:29 AM
The link was http://www.excelforum.com/excel-programming-vba-macros/950072-generate-number-when-userform-information-is-submitted.html