?
Solved

validating records on a continuous form

Posted on 2005-03-18
6
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

801 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