Data Validation on Continuous Forms (1 Viewer)

wsaccess

Registered User.
Local time
Today, 04:51
Joined
Dec 23, 2015
Messages
38
Hi,

I have a table with 2 sets of fields: Plans and Actuals.
Plan Fields have values and Actual Fields are empty for the user to fill in from the Form.
I have a continuous form with Record Source as the above table.
When the Form opens, the Plans are displayed on the Form and User enters the Actuals.

Questions:

1. I have a Command Button Submit.
When the button is pressed, I want to do a data validation on all the records in the form. How do I do that?

2. I have a button to Add Record. On Form Load, AllowAdditions is false. When 'Add' is pressed, AllowAdditions is True. When I add the 1st record, everything is fine. When I add the 2nd record, the very first record disappears from the Form view. (That Record still existsthere as I can see from the Navigation bar the correct count). How to stop the 1st record from disappearing?
 

Ranman256

Well-known member
Local time
Yesterday, 23:51
Joined
Apr 9, 2015
Messages
4,337
I have a table that holds queries
[Qry],[Batch]
qsBadCity, "client"
qsBadSoc, "client"

these are my lists of validation queries
so when entering client data then a macro runs these.
the queries pull data that is incorrect, and has a field: Reason: 'No Address given'

the macro opens them all, if the query has data then it failed validation
ID field will help locate the error.
 

wsaccess

Registered User.
Local time
Today, 04:51
Joined
Dec 23, 2015
Messages
38
That sounds like another way of data validation.

I managed to find the following code in the internet and it is working as I wanted:

Private Sub cmdSubmit_Click()

Dim rs as DAO.Recordset

Set rs = Me.RecordsetClone
rs.MoveFirst

Do While NOT rs.EOF
IF IsNull(rs!Field1.Value) Then
Msgbox("Field cannot be blank")
Me.Bookmark = rs.Bookmark
Me.Field1.SetFocus
Exit Sub
End If
Loop

Set rs = Nothing

End Sub

It validates the fields row by row, and sets the cursor on the 1st field which is wrong.

So that solves one of my questions.

However, I couldn't resolve my second problem yet.
The rows disappearing at the top when new records are added in the Form.

Anyone, please?
 

Users who are viewing this thread

Top Bottom