Results 1 to 11 of 11
  1. #1
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14

    Loop continous form

    Hi guys,



    I 've a problem, I have a continous form and when the form is loading it should check if "me.txtmessage" = true, output a msgbox with "me.txtname" and go on to the next record.

    I only get the msgBox from the first record as often as the recordcount, or an error 2046, that I cant move to the next record.

    My Code:

    Private Sub Form_Load()
    While Me.CurrentRecord < Me.Recordset.RecordCount
    If Me.txtmessage = true Then
    MsgBox Me.txtname
    End If
    DoCmd.GoToRecord Record:=acNext
    Wend
    End Sub

    Please help me
    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What are you really trying to accomplish? Why throw up message boxes?

    Tested the code and it works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14
    The "If" is a placeholder for my later fuction and I will change the msgBox by an email send function. This code is just a test for me to try if it works.

    I also tried this code:

    Dim rsf As Recordset
    set rsf = me.RecordsetClone
    rsf.movefirst
    Do Until rsf.EOF
    If Me.txtmessage = true Then
    MsgBox Me.txtname
    End If
    End If
    rsf.movenext
    loop

    It didnt work either.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Your second code shows an extra End If. However, even removed code won't work because it is pulling values from the form not from the RecordsetClone.

    This worked:

    Code:
    With Me.RecordsetClone
    Do Until .EOF
        If !txtmessage Then
            MsgBox !txtname
        End If
        .MoveNext
    Loop
    End With
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14
    Thanks, but I only get the name from the first record several times.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't know why. Both approaches work perfectly for me. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14
    I tried it on a new database but it didn't work there either.
    Here is a link to my database: https://drive.google.com/open?id=1Sd...hjzRmg4pRjQjnA
    In the original one are more records and it is splited into frontend and backend.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The code is in the Current not Load event.

    There are no fields named txtmessage and txtname. The RecordsetClone code is referencing the controls on form and since focus remains on record 1 only those values are read.

    This works:
    Code:
    Private Sub Form_Load()
    With Me.RecordsetClone
    Do Until .EOF
        If !Feld2 Then
            MsgBox !Feld1
        End If
        .MoveNext
    Loop
    End With
    End Sub
    I also tested your original code (copy/paste, no changes) and it works.

    Big difference between the two methods is the first actually navigates records on the form so when it's done focus is on last record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14
    There shown name is not there system name, in the system they are named as I written. The code doesnt work again. I put some pictures in the attachment.Click image for larger version. 

Name:	Unbenannt.PNG 
Views:	6 
Size:	5.2 KB 
ID:	31523Click image for larger version. 

Name:	Unbenannt2.PNG 
Views:	5 
Size:	6.0 KB 
ID:	31524Click image for larger version. 

Name:	Unbenannt3.PNG 
Views:	5 
Size:	5.8 KB 
ID:	31525

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Textboxes are named txtname and txtmessage. Fields are named Feld1 and Feld2. Use the code I provided in post 8.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    mb4673 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2017
    Posts
    14
    Ok that was the problem, thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 04-29-2015, 09:37 AM
  2. Replies: 9
    Last Post: 04-16-2015, 09:54 AM
  3. Sort on Continous Form?
    By NotaryEtc in forum Forms
    Replies: 3
    Last Post: 04-19-2014, 08:35 AM
  4. Checkbox in continous form
    By senthilrg in forum Access
    Replies: 11
    Last Post: 12-05-2009, 08:49 AM
  5. Horitontal Continous Form?
    By Lawrence in forum Forms
    Replies: 1
    Last Post: 07-21-2009, 03:06 PM

Tags for this Thread

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