Can't go to Specified record (1 Viewer)

wisertime

New member
Local time
Today, 10:05
Joined
Jul 22, 2008
Messages
1
I recently took on a small Access project. I moved everything to a SQL backend (i'm a SQL Dba, not an Access person) and one of the forms isn't working. This is basically a form that collects information and posts it to the linked SQL table.

Whoever wrote the code added a Clear button at the top and specified to click it before adding a new record. Here is the code for the button.

Private Sub cmdClear_Click()
' Set Screen values to zero
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Methadone = Null
D = Null
DIA = Null
CELEX = Null
K = Null
ZY = Null
Hydrox = Null
A = Null
G = Null

Methadone.SetFocus

It is erroring out on the DoCmd line, stating that You can't go to the specified record. This worked when the table was an Access table, but when it moved to SQL it errored. There is a primary key on an ID field that shows up when the form is loaded. I thought that SQL can't advance a record like Access can, but I am unfamiliar with what this line of code means. can anyone help??
 

SQL_Hell

SQL Server DBA
Local time
Today, 18:05
Joined
Dec 4, 2003
Messages
1,360
Does the table have a primary key?

Can you add a new record by opening the table in data sheet view?

What happens if you replace your DoCmd.GotoRecord with:


DoCmd.GoToRecord , , acNewRec
 

Users who are viewing this thread

Top Bottom