vbams-accessselectdatasheetnewrow

Access vba select new raw in datasheet view


I have a datasheet view form. I want to add in it but when i set focus cause of sorting it select the top record which has data in it and edit it. Question is how I can select the new row which has * beside it, so when I set focus it will create a new record.

HOW TO SELECT THE NEW RAW OF A DATASHEET VIEW FORM WITH VBA CODE?


Solution

  • You can just insert your new record with something like this:

    DoCmd.RunSQL("insert into table1 (field1, field2)
        values( " & value1 & ", " & value2 & ")"
    

    (or use parameters, that would be better), then do the SetFocus on your datatsheet.