Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

validating records on a continuous form

Posted on 2005-03-18
6
Medium Priority
?
305 Views
Last Modified: 2012-06-27
I have a continuous form that the user selectively enters data on. Upon completion of their data entry (command button pressed) I want to validate each record on the form.

How can I reference a control on each record on the form starting with the first row and ending with the last??

Please advise.

Thanks,
Tom
0
Comment
Question by:TPrugno
  • 3
  • 3
6 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 2000 total points
ID: 13578641
You can't. You can reference fields in the underlying recordset by either directly referencing the form's recordset or a clone of it, but that's as much as you can do (which is probably sufficient for what you need to do).

However, can you not simply validate the data of the current record instead, so that each record is validated as they enter/alter it?

To use the recordset method, you'd need some code like this:

Dim rst As DAO.Recordset

Set rst=Me.RecordsetClone
rst.MoveFirst
While Not rst!.EOF
   'Check if MyField is null, for example
   If IsNull(rst!MyField) Then
      'Do something
   End If
   rst.MoveNext
Wend
rst.Close
Set rst=Nothing
0
 

Author Comment

by:TPrugno
ID: 13578912
Thanks.

Follow-up question ...

If I detect an error, how can I set the focus to the specific field and row in error?

Tom
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13578974
Use the BookMark property to navigate the form to the correct record:

Me.BookMark=rst.BookMark

You can now set the focus to the appropriate textbox according to whichever field you are checking - for example:
If IsNull(rst!MyField) Then
   Me.BookMark=rst.BookMark
   Me.txtMyField.SetFocus
   rst.Close
   Set rst=Nothing
   Exit Sub
End If
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TPrugno
ID: 13578991
I tried the code you provided and got a compile error on the DIM statement:

User define type not defined

I'm not familar with "DAO.recordset"  

Can you review this and point me in the right direction?
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13579011
If you're using A2K or later, you need to add a reference to DAO in. In the VBA window, click Tools->References and make sure Microsoft DAO 3.6 (or 3.5) is checked, and the code should work ok.
0
 

Author Comment

by:TPrugno
ID: 13579082
Once again, you did it!!

Thanks very much.
Tom
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question