Contiuous Form Next Record Selector Problem

workolic

New member
Local time
Today, 20:17
Joined
Oct 3, 2012
Messages
3
Hi all,

Below is the code which I use to retrieve data from a different Database. I want to put data in a Continuous Form. There is no problem retrieving data but the Continuous From does not go to the next Record Selector.
I have tried commands below without success:
DoCmd.RunCommand acCmdInsertRows
DoCmd.GoToRecord , , acNewRec


Code:
....
Set db = OpenDatabase("D:\Test.mdb")
strSql = "SELECT Table1.* FROM Table1 WHERE strSO = '" & vbSO & "'"
Set rs = db.OpenRecordset(strSql, dbOpenDynaset)
         
rs.MoveFirst

If (Not IsNull(rs!CorroID)) Then
Do Until rs.EOF
    
  Me.txtID.SetFocus
  Me.txtID1.Value = rs!CorroID
etc...
  
  DoCmd.GoToRecord , , acNewRec    '##Problematic line## 
  Me.Requery
    
  rs.MoveNext
Loop
End If
...

I do not have any error.

Any help will be appreciated.

Thanks.
 
Thanks. Already tried. But this does not work.
I am missing something more obvious than that: see the single record selection in my form.
 

Attachments

if the query that returns your records is non-updatable - you will find you cannot add records, or edit records with the form.

that is probably the issue.

it may also be a form setting that you can select where you can turn off these facilities manually - allow edits, allow additions etc

as you are getting records from a separate database, in a fairly unusual way, i suspect the first issue is the problem.
 
By doing a requery after going to a new record it moves to the first record, the requery is not required.

I agree with gemma-the-husky that it's an unusual way to retrieve data from another db. An append query would be easier.

Some other notes made in your code below.

Code:
rs.MoveFirst [COLOR="SeaGreen"]'on an empty recordset this will fail, you should test this[/COLOR]
'If (Not IsNull(rs!CorroID)) Then [COLOR="SeaGreen"]'if you do the test here it will not happen in the loop again[/COLOR]
Do Until rs.EOF

   [B]If (Not IsNull(rs!CorroID)) Then 
      DoCmd.GoToRecord , , acNewRec[/B]  [COLOR="seagreen"]'move here to avoid problems when records are already there [/COLOR]
      Me.txtID.SetFocus
      Me.txtID1.Value = rs!CorroID
      etc...
   [B]end if  [/B]  
'  DoCmd.GoToRecord , , acNewRec    '##Problematic line## [COLOR="seagreen"]'should be moved before the insert.[/COLOR] 
' Me.Requery not required here
    
  rs.MoveNext
Loop
 
gemma-the-husky, you are right: my records are non-updatable.

Do you have a usual way to retrieve data?

Thanks.

Code:
???
Set db = OpenDatabase("D:\Test.mdb")
strSql = "SELECT Table1.* FROM Table1 WHERE strSO = '" & vbSO & "'"
Set rs = db.OpenRecordset(strSql, dbOpenDynaset
???
 
i think i would just create a link to the table in the other database, as with any other linked table.
 

Users who are viewing this thread

Back
Top Bottom