Need VB code for add sequential records to table

D

Danny M

I need the code for adding sequential records to a table.

My table name is "WiresOut"
My field for updating is "Number" and is a text field
My field on the form is "Number"
My Starting number "B0000"

Any help would be appreciated
 
K

Keith W

Danny M said:
I need the code for adding sequential records to a table.

My table name is "WiresOut"
My field for updating is "Number" and is a text field
My field on the form is "Number"
My Starting number "B0000"

Any help would be appreciated
You can have sequential numbers by setting a textbox default value to (IIRC)
"=DMax([MyNumberField])+1". You'd need to handle nulls if you're supplying
an empty database to your user(s). If the alpha part of the "number" is
always the same then there's no need to store it. BTW I wouldn't user
"Number" as a field name as it may cause confusion when you come to write
code.

HTH - Keith.
www.keithwilby.com
 
D

Danny M

Keith

what is (IIRC)

Keith W said:
Danny M said:
I need the code for adding sequential records to a table.

My table name is "WiresOut"
My field for updating is "Number" and is a text field
My field on the form is "Number"
My Starting number "B0000"

Any help would be appreciated
You can have sequential numbers by setting a textbox default value to
(IIRC) "=DMax([MyNumberField])+1". You'd need to handle nulls if you're
supplying an empty database to your user(s). If the alpha part of the
"number" is always the same then there's no need to store it. BTW I
wouldn't user "Number" as a field name as it may cause confusion when you
come to write code.

HTH - Keith.
www.keithwilby.com
 
D

Danny M

Keith

I put this code in the text box default value and received a error when i
pulled the form up.

Keith W said:
Danny M said:
I need the code for adding sequential records to a table.

My table name is "WiresOut"
My field for updating is "Number" and is a text field
My field on the form is "Number"
My Starting number "B0000"

Any help would be appreciated
You can have sequential numbers by setting a textbox default value to
(IIRC) "=DMax([MyNumberField])+1". You'd need to handle nulls if you're
supplying an empty database to your user(s). If the alpha part of the
"number" is always the same then there's no need to store it. BTW I
wouldn't user "Number" as a field name as it may cause confusion when you
come to write code.

HTH - Keith.
www.keithwilby.com
 
L

Larry Linson

IIRC = If I Recall Correctly

Danny M said:
Keith

what is (IIRC)

Keith W said:
Danny M said:
I need the code for adding sequential records to a table.

My table name is "WiresOut"
My field for updating is "Number" and is a text field
My field on the form is "Number"
My Starting number "B0000"

Any help would be appreciated
You can have sequential numbers by setting a textbox default value to
(IIRC) "=DMax([MyNumberField])+1". You'd need to handle nulls if you're
supplying an empty database to your user(s). If the alpha part of the
"number" is always the same then there's no need to store it. BTW I
wouldn't user "Number" as a field name as it may cause confusion when you
come to write code.

HTH - Keith.
www.keithwilby.com
 
K

Keith W

Danny M said:
Keith

I put this code in the text box default value and received a error when i
pulled the form up.
What *exactly* did you put in the box and what error did you receive?
 
D

Danny M

Keith

I put the following code

"=DMax([Control])+1"

i took your suggestion and changed the field to Control
The error is #error in the field when i pull the form up
i also tried it like this =DMax([Control])+1

thanks
danny
 
K

Keith W

Danny M said:
Keith

I put the following code

"=DMax([Control])+1"

i took your suggestion and changed the field to Control
The error is #error in the field when i pull the form up
i also tried it like this =DMax([Control])+1

My apologies, the correct format is

DMax("[FieldName]","TableName")+1

If the table empty then try using the null to zero function:

nz(DMax("[FieldName]","TableName"),0)+1

HTH - Keith.
www.keithwilby.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top