Generating a rank of data on a table via form.

rodvaN

Registered User.
Local time
Yesterday, 23:07
Joined
May 20, 2009
Messages
92
Hello again..
I would like to know the VBA of generating data from a form.
I use 2 textboxes.. Data 1 and Data 2
I write A001 on Data 1
then .. I write A010 on Data 2..
I press generate button, then on the table it will automatically generate from A001, A002, A003, A004, A005, A006, A007, A008, A009 and A010.
Im breaking my head on this one. would truly appreciate help.
Thanks in advance.
 
Is your data always going to be in the format Alpha,Numeric,Numeric,Numeric?

If not, could you elaborate further on what the data field limits are?

For instance, is the data always prefixed by a Alpha or Alphas and then followed by numerics, etc, etc
 
Yes it is going to be Alpha, number, number, number.
The limits are 200 cells if I generate from A001 to A201, it shows me a "dont flood the system" message..
Data 1 : A001 Data 2 : A005
A001
A002
A003
A004
A005
on the table database.
Hope that explains me.
Thanks in advance.
 
you dont need code

your query needs to select accounts

"between textboxa and textboxb"


rather than testing the textboxes, i would test the number of items returned in the query

if dcount("*","myquery")>whatever
 
What you need is something like this:
(I've assumed the code will be attached to the form)
PHP:
Set db=CurrentDB
set rs=db.OpenRecordset("TABLENAME")
For x = Val(Right(me!Data1,3)) To Val(Right(me!Data2,3))
    rs.AddNew
    rs!FieldName=left(Me!Data1,1) & String(4-Len(x),"0") & x
    rs.Update
Next

HTH
 
Thank you so much for the answer PearlGI..
I was wondering if Data1 and Data2 were the names of the textboxes fields?
The fieldname is the column in the table?
What action the button going to have?, saverecords?

Could you please do an example.. I really appreaciate further help since Im newbie in this.
Yours..
rodvaN
 
Data1 and Data2 would be the names of your textbox fields.

FieldName is the 'column' in your table. If the column name contains a space then ensure that you put square brackets [] around the name.

Regarding the action, I suggest that you put the code into the 'On Click' event of the button.
 
Thank you very much!
It worked like a charm! Im in a big debt with you.

rodvaN
 
In case there are duplicated fields and I create a None duplicated field on table, how can I add an error message when it detects a duplicated entry?
How can I add another error message with a data is not typed on Data 1 or Data 2?.

I added a click err..
-----------------------
rs.AddNew
rs!Almacen = Left(Me!Data1, 1) & String(4 - Len(x), "0") & x
Command5_Click_Err:
MsgBox "Error de duplicacion", vbOKOnly ---- there
rs.Update
Me.Refresh
---------------------
But it keeps showing me other error, the debug error.





My most sincere apologize if Im being annoying.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom