Solved Some Code executing, some not executing on a form event (1 Viewer)

Tom d

Member
Local time
Today, 03:21
Joined
Jul 12, 2022
Messages
47
You have an input mask on the date control? :( I hate input masks.
Anyway I entered todays date with ctrl & ; and get 'Datcannot be in the future????

I changed it to 23/07/2022 as you can see, then tried to move to next record. Pic below

Why is form selections using the table? Could not open table in design view until I close a form that should have nothing to do with tables?, it is a switchboard form type after all?

Edit: I found out why, you have < Date() in the validation rule on the control properties. ? :( Should be <= Date() ???
FWIW I would have your validation in one place. You have bits in the table, bits in the control properties and bits in code? :(
Absolutely a nightmare to track down, especially when you do not know the DB. :(

The experts here will advise the best method.

View attachment 101984
I add a switchboard to your data base.
The Data Base never adds a new record to the table, I am totally confused.
 

Attachments

  • Gasman Blood Pressure.accdb
    1.4 MB · Views: 80

Gasman

Enthusiastic Amateur
Local time
Today, 07:21
Joined
Sep 21, 2011
Messages
14,050
I add a switchboard to your data base.
The Data Base never adds a new record to the table, I am totally confused.
That is rubbish. :(

All I have done is allow you to choose when to add a record(s).
If all you EVER want to do with that form is add records, never be able to view any of them without another form, or playing with that setting, making things more complex at this stage, then put the data entry back to Yes.

I myself prefer to have a form that will do both, and tend to use the buttons at the bottom as I have said before.
1658730928565.png

I use that button to the right of the ->| button.
If you want to go to the last entered record each time you open the form, then put

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub
into the form.
You could even have
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
which will go to the new record on load, but still allow access to previously entered records.
I doubt very much you never make mistakes in entering data?, I know that I still do.

In fact this might be a good choice for a split form?

1658731416693.png
 

Tom d

Member
Local time
Today, 03:21
Joined
Jul 12, 2022
Messages
47
That is rubbish. :(

All I have done is allow you to choose when to add a record(s).
If all you EVER want to do with that form is add records, never be able to view any of them without another form, or playing with that setting, making things more complex at this stage, then put the data entry back to Yes.

I myself prefer to have a form that will do both, and tend to use the buttons at the bottom as I have said before.
View attachment 101995
I use that button to the right of the ->| button.
If you want to go to the last entered record each time you open the form, then put

Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub
into the form.
You could even have
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
which will go to the new record on load, but still allow access to previously entered records.
I doubt very much you never make mistakes in entering data?, I know that I still do.

In fact this might be a good choice for a split form?

View attachment 101996
Thanks for all your help.
 

Users who are viewing this thread

Top Bottom