I created a form in Access to store and retrieve data from a sql server table.
When i go and try to add a record to the form - i get the error: Unique Table is nonexistent or not completely specified
however if i try to add the same record to the backend database (in sql server), it gets added perfectly. What am i doing wrong?
I am using an field called recno as my unique identifier, it is to increment by 1 whenever i add a new record. i notice that when trying to add a new record through access - the new number does not display, it displays a # and never gets to a number, then i get the error.
here's the code behind my form.
Option Compare Database
Private Sub btnRefresh_Click()
Call PopulateData
End Sub
Private Sub Form_Load()
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Detail.Visible = True
Me.cbxAcYear.DefaultValue = 2008
Me.cbxQuarter.DefaultValue = 1
End Sub
Sub PopulateData()
Dim sqltext As String
'---- Form datasource
sqltext = "Select * from SuperSchoolAttendance " & _
"where acyear=" & Me.cbxAcYear & _
" and quarter=" & Me.cbxQuarter & _
" order by 1"
'Debug.Print sqltext
Me.RecordSource = sqltext
Me.txtAcYear.DefaultValue = Me.cbxAcYear
Me.txtQuarter.DefaultValue = Me.cbxQuarter
Debug.Print sqltext
Me.Refresh
Me.Detail.Visible = True
End Sub
Private Sub cbxAcyear_AfterUpdate()
' Call PopulateData
End Sub
Private Sub CommandDelete_Click()
Dim ok As Integer
ok = MsgBox("Are you sure you want to delete " & _
Me.txtRecno & "?", vbOKCancel, "Warning")
If ok = vbOK Then
Dim sqltext As String
sqltext = "Delete from SuperSchoolAttendance " & _
"where recno=" & Me.txtRecno
DoCmd.RunSQL sqltext
Me.Refresh
End If
End Sub
Private Sub btnAdd_Click()
Me.AllowAdditions = Not Me.AllowAdditions()
End Sub