Form number string to mm/dd/yyyy in a table

  • Thread starter Thread starter Slippery_1 via AccessMonster.com
  • Start date Start date
S

Slippery_1 via AccessMonster.com

I need my form input text box (for ease) to be a number string e.g. 091805
that will convert to mm/dd/yy.
Any pointers? I searched thru 25 pages here.
TIA
Slippery_1
 
Slippery_1 via AccessMonster.com said:
I need my form input text box (for ease) to be a number string e.g. 091805
that will convert to mm/dd/yy.


You should probably also check to make sure the data that
was entered is what you expect it to be. Then it can be
converted without getting an error:

Dim dtvar As Date
If Len(Me.textbox) = 6 _
And Not (Me.textbox Like "*[!0-9]*") Then
dtvar = DateSerial(Me.textbox Mod 100, _
Me.textbox \ 1000, (Me.textbox \ 100) Mod 100)
? ? ?
Else
Beep
End If

You never said what you want to do with the date variable.
 
Dim dtvar As Date
If Len(Me.textbox) = 6 _
And Not (Me.textbox Like "*[!0-9]*") Then
dtvar = DateSerial(Me.textbox Mod 100, _
Me.textbox \ 1000, (Me.textbox \ 100) Mod 100)
? ? ?
Else
Beep
End If

You never said what you want to do with the date variable.

I want to pass the string from my form to a table:
Table (SerialData)
Field (DateInstalled)
 
Marshall said:
Dim dtvar As Date
If Len(Me.textbox) = 6 _
And Not (Me.textbox Like "*[!0-9]*") Then
dtvar = DateSerial(Me.textbox Mod 100, _
Me.textbox \ 1000, (Me.textbox \ 100) Mod 100)
? ? ?
Else
Beep
End If

You never said what you want to do with the date variable.
Slippery_1 via AccessMonster.com said:
I want to pass the string from my form to a table:
Table (SerialData)
Field (DateInstalled)


If that table is bound to the current form, then just assign
the value to the text box bound to the field:
Me.txtdatefield = dtvar

If the table is not bound to the form, then we still more
details before explaining how to locate the record that
should be updated.
 
Marshall said:
[quoted text clipped - 15 lines]
Table (SerialData)
Field (DateInstalled)

If that table is bound to the current form, then just assign
the value to the text box bound to the field:
Me.txtdatefield = dtvar

If the table is not bound to the form, then we still more
details before explaining how to locate the record that
should be updated.

I uploaded the File to my website.

http://chadhammer.com/access/SN-Data.mdb

Maybe you could take a look. I intend to offer it free to anyone who wants it
anyways.

My goal is to be able to scan or type a serial number on a product into a
form. It changes focus to the date input on the form. User enters the date.
Hits the enter key and the form input text boxes clear and focus changes back
to the serial number for the next serial number to scan in or hand enter.

The next part of my serial number database will have a serial number
retrieval form. Enter a serial number, it will output the product type, the
date installed and serial number of the product that replaced it (if there is
one). I might like it to flash red text if "out of warranty" as well.

Thank for the replies and help thus far. I greatly appreciate it!!!!! :)

I took an Access class at the community college. Very little about VB
Scripting in it though. Will try staying at a Holiday Inn. Maybe that will
help. LOL
 
Slippery_1 via AccessMonster.com said:
Marshall said:
I need my form input text box (for ease) to be a number string e.g. 091805
[quoted text clipped - 15 lines]
Table (SerialData)
Field (DateInstalled)

If that table is bound to the current form, then just assign
the value to the text box bound to the field:
Me.txtdatefield = dtvar

If the table is not bound to the form, then we still more
details before explaining how to locate the record that
should be updated.

I uploaded the File to my website.

http://chadhammer.com/access/SN-Data.mdb

Maybe you could take a look. I intend to offer it free to anyone who wants it
anyways.

My goal is to be able to scan or type a serial number on a product into a
form. It changes focus to the date input on the form. User enters the date.
Hits the enter key and the form input text boxes clear and focus changes back
to the serial number for the next serial number to scan in or hand enter.

The next part of my serial number database will have a serial number
retrieval form. Enter a serial number, it will output the product type, the
date installed and serial number of the product that replaced it (if there is
one). I might like it to flash red text if "out of warranty" as well.


Sorry, no downloads. Besides I will be away the rest of the
week. You should ask your question in a new thread and
maybe someone else will pick up from here.

Your objective may be all well and good, but it doesn't tell
me how you form is configured. I can't be sure, but I
stongly suggest that you bind the form to a table. This
allows you to just copy the value to a bound text box as I
posted earlier. To "clear" the form for the next serial no,
just move to a new record.
 
set the format for the field to mm/dd/yy
set the input mask to 99/99/00;_

that way your field doesn't have to be text, it can be date/time input, to
match where you want to store it as a date...

give it a try

Dubbo Pete
 
DubboPete said:
set the format for the field to mm/dd/yy
set the input mask to 99/99/00;_

that way your field doesn't have to be text, it can be date/time input, to
match where you want to store it as a date...

give it a try

Dubbo Pete

Thank you very much! I remember that now. Getting old & dusty upstairs in the
brain pan.
 
Marshall said:
Sorry, no downloads. Besides I will be away the rest of the
week. You should ask your question in a new thread and
maybe someone else will pick up from here.

Thanks for replying! Have a good rest of the week! :)
 
Back
Top