Hello to the esteemed members of Access World. (1 Viewer)

pdrua

New member
Local time
Today, 10:44
Joined
Oct 3, 2023
Messages
8
Thank you all for your selfless assistance.

I am working on MS Access Forms. I set a textbox field date input but when I entered the dates I received the following error. I searched many resources but could not locate the correct solutions.
1696294325900.png

Attached here is the screenshot
1696294325900.png
 

Jon

Access World Site Owner
Staff member
Local time
Today, 10:44
Joined
Sep 28, 1999
Messages
7,466
Welcome to Access World! We're so happy to have you join us as a member of our community. As the most active Microsoft Access discussion forum on the internet, with posts dating back more than 20 years, we have a wealth of knowledge and experience to share with you.

We're a friendly and helpful community, so don't hesitate to ask any questions you have or share your own experiences with Access. We're here to support you and help you get the most out of this powerful database program.

To get started, we recommend reading the post linked below. It contains important information for all new users of the forum:

https://www.access-programmers.co.uk/forums/threads/new-member-read-me-first.223250/

We hope you have a great time participating in the discussion and learning from other Access enthusiasts. We look forward to having you around!
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:44
Joined
Feb 19, 2013
Messages
16,685
thread moved to appropriate forum

@pdrua - you need to provide more information - the error message is clear enough, but need to know the field type (perhaps wrong in your table design). And also what are you actually entering
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:44
Joined
Oct 29, 2018
Messages
21,556
Hi. Welcome to AWF!

Are you using any code to update the table?
 

pdrua

New member
Local time
Today, 10:44
Joined
Oct 3, 2023
Messages
8
Thank you for your prompt response. Appreciate it!

I have an unbound textbox on the form, the format is set to Short Date, and Input Mask is also set to accept Short Date. No code.

I entered/edited the date in its correct format and when the textbox lost focus the posted error was displayed.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:44
Joined
Oct 29, 2018
Messages
21,556
Thank you for your prompt response. Appreciate it!

I have an unbound textbox on the form, the format is set to Short Date, and Input Mask is also set to accept Short Date. No code.

I entered/edited the date in its correct format and when the textbox lost focus the posted error was displayed.
If you remove the input mask, do you still get the error? If so, please post any code you may have behind the textbox.
 

pdrua

New member
Local time
Today, 10:44
Joined
Oct 3, 2023
Messages
8
If you remove the input mask, do you still get the error? If so, please post any code you may have behind the textbox.
I removed the Input Mask but got the same error. I even changed the date format to Medium Date but the error persisted.

The textbox is unbound and has no events attached to it or no codes under it.

I am using Office 2013. There may be some known compatibility issues...????
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:44
Joined
Oct 29, 2018
Messages
21,556
I removed the Input Mask but got the same error. I even changed the date format to Medium Date but the error persisted.

The textbox is unbound and has no events attached to it or no codes under it.

I am using Office 2013. There may be some known compatibility issues...????
In that case, I would recommend posting a sample for testing.
 

pdrua

New member
Local time
Today, 10:44
Joined
Oct 3, 2023
Messages
8
In that case, I would recommend posting a sample for testing.
Thank you Sir.

I have decided to work around it. I set the Default value of the Textbox to date by using =Date()

Here is the screenshot of my form. The date textbox is indicated in a red square box with its default value set to the current date.
1696309015343.png

I then use the following code upon the Textbox Lost Focus event to verify and set the date format.

Private Sub txtFirstRepaymentDate_LostFocus()
Dim startDate As Date

If Not IsNull(Me.txtFirstRepaymentDate.Value) Then
startDate = Format(Me.txtFirstRepaymentDate.Value, "dd/mm/yyyy")
End If

End Sub

Thank you so much for your time and assistance.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:44
Joined
Feb 28, 2001
Messages
27,348
Just FYI, ".value" is the default for any control type that actually HAS a value. You can generally omit it from form and report references; just use the control name. So just use Me.txtFirstRepaymentDate and the .Value will take care of itself.

Now, the next question is, what were you PLANNING to do with the computed value in StartDate? Because at the moment you do NOTHING with it. It is declared as a local DATE variable, so you aren't returning it. Once you have it, you don't try to store it in a more permanent place.

You should also realize that you have a DATE variable receiving the output of a FORMAT function, which is a string. So like the error message says, you really ARE putting text into a numeric field.
 

pdrua

New member
Local time
Today, 10:44
Joined
Oct 3, 2023
Messages
8
Just FYI, ".value" is the default for any control type that actually HAS a value. You can generally omit it from form and report references; just use the control name. So just use Me.txtFirstRepaymentDate and the .Value will take care of itself.

Now, the next question is, what were you PLANNING to do with the computed value in StartDate? Because at the moment you do NOTHING with it. It is declared as a local DATE variable, so you aren't returning it. Once you have it, you don't try to store it in a more permanent place.

You should also realize that you have a DATE variable receiving the output of a FORMAT function, which is a string. So like the error message says, you really ARE putting text into a numeric field.
Thank you.

Very useful information.

I will be using the StartDate value to calculate the loan repayment schedules and save the data in the loan repayment table.

Thank you so much. You guys are Super!
 

mike60smart

Registered User.
Local time
Today, 10:44
Joined
Aug 6, 2017
Messages
1,917
Why not bind the Controls so that the data is stored directly without any code?
 

Users who are viewing this thread

Top Bottom