Adding data to a table from an unbound form using VBA

mhwins94

New member
Local time
Today, 21:55
Joined
May 9, 2012
Messages
4
I have a form that isn't bound to a table, so it's for users to enter their own data (registeration form), I don't want the current data from the table shown in the form, hence why it's unbound. Also there is a field in the table that I want to send the data into, age category, if the user has inputted their age as between 11-18 then it has to be stated in the table as junior, 18-40 adult and 40+ senior,any ideas on what the code would be, this is a basis on what I have so far;
Code:
If Me.Age < 11 > 18 Then DoCmd.GoToRecord , , acNewRec
I am not entirely sure as I am relatively new to using vba
many thanks in advance
 
If you're new to VBA then I and I think everyone would advise you not to try to do this with an unbound form. That will take quite a lot of code and needs some understanding of how to do it. Otherwise you'll get yourself into a terrible mess.

You can make a bound form behave as you need here by making it into a data entry form or opening it with the acFormAdd argument:
DoCmd.OpenForm "Form1", , , , acFormAdd

That is much the better way to do it.

Also, why not store the date of birth and calculate the age and/or age bracket from that. Ages stored in tables go out of date quite quickly ;)
 
hi,

it will be better to create an another table in which u can store category and range and use this date for Combobox instead text box and update the desired table with a sqlstatement on afterupdate event this combobox

enjoy!!!!!!!!!!
 

Users who are viewing this thread

Back
Top Bottom