Results 1 to 6 of 6
  1. #1
    TenOc is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2015
    Posts
    94

    I have been struggling with my "if statement" and my "do until end of file statement"

    Windows 10 Access office LTSC Professional plus 2021




    I only make changes to our access program every year to so; therefore, my programming skills get rusty. I am struggling with a new task and I am sure that you can help me.


    I have a form (call it form 1) which data comes from a table (call it table A). Form 1 has a number of fields but for this discussion we will call these fields STATE and CITY. These are not their real names but will make it easier to understand my problem. Employee 1 enters data into a number of the fields on form 1. Employee 2 then enters data into more fields including the field I am calling CITY and STATE. These two fields are entered using cascading combo boxes. So far everything is working well


    The problem arises if employee 2 fails to enter data into these 2 fields or enters an empty string. Because of some legacy data and other complications, I cannot make these 2 fields required fields. My solution is to add a button (call it check for errors) to step through all the records in table A and locate those that have either a null value or an empty string. The last few days I have been struggling with my if statement and my do until end of file statement loop to find these errors.


    I thought about posting my code here. But I recognize that it is written so amateurish that probably would be different for you to understand what I’m trying to do because I have added a number of MessageBox comments and other tools including commented out code that I have tried that did not work that it would be better if you could give me some sample code that will start me down the right track.


    Any help would be welcome.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    It still gives someone something to work with. ��
    Otherwise they are just guessing, and computing and guessing do not work well together?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    post your code - ensure you use code tags (the # button) to preserve indentation.

    Otherwise it is just guesswork since there are several ways to check for 'required'

  4. #4
    TenOc is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2015
    Posts
    94
    I found a simpler way, but you coding experts may not like it. I put a button that sorts the data by these 2 fields so if they do not contain the valid data they go to the top of the view list. I'm declaring this problem solved.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Why would you need a loop for this? If you want to return these records to the form so that you can manually fill in the missing data, filter the form based on the field(s) so that it shows records that are null and "" as well.

    If you're saying you cannot design the table field to be required, you can enforce those fields to have values IF some other field(s) already has data if that would work with your process. If not, back to the original question - why the loop? You may not need it at all. Last, did you put a break point on your code and watch it execute line by line? That might reveal a problem.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    TenOc is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Feb 2015
    Posts
    94
    Quote Originally Posted by Micron View Post
    Why would you need a loop for this? If you want to return these records to the form so that you can manually fill in the missing data, filter the form based on the field(s) so that it shows records that are null and "" as well.
    VERY good suggestion. I may try it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-03-2021, 03:10 PM
  2. Replies: 3
    Last Post: 10-30-2019, 09:37 PM
  3. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  4. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  5. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums