G
Guest
Hey,
I use the functionality of access to Add a record to a table.
When yoy type >* (add) on the screen I haven blank field to fill up. When I
leave the firts field (ID) i want to check if the ID don't already exists in
the table. I do this with the following code.
Private Sub ID_AfterUpdate()
Dim strSQL As String
Dim rst As Recordset
' Zoek dubbel, geef fout
' Bestaat deze duif
Set rst = CurrentDb.OpenRecordset("Select * FROM Duiven WHERE
[Duiven]![ID] = '" & Me!ID & "'", dbOpenDynaset)
If rst.RecordCount > 0 Then
MsgBox "Deze Duif bestaat reeds"
Set rst = Nothing
Exit Sub
Else
Set rst = Nothing
End If
End Sub
My question is : When it exists i show a messagebox. But when I click OK in
that messagebox I want that my form (it is not a grid, but it show a record
by record) shows me the last inputed record and that the user must click
again on >* to add a record.
My seqond question: When you are entering a new record and you don't wont to
finishing it, how you can avoid that the record is inserted in the table? Or
how you can put it out of the table
Thanks,
jac
I use the functionality of access to Add a record to a table.
When yoy type >* (add) on the screen I haven blank field to fill up. When I
leave the firts field (ID) i want to check if the ID don't already exists in
the table. I do this with the following code.
Private Sub ID_AfterUpdate()
Dim strSQL As String
Dim rst As Recordset
' Zoek dubbel, geef fout
' Bestaat deze duif
Set rst = CurrentDb.OpenRecordset("Select * FROM Duiven WHERE
[Duiven]![ID] = '" & Me!ID & "'", dbOpenDynaset)
If rst.RecordCount > 0 Then
MsgBox "Deze Duif bestaat reeds"
Set rst = Nothing
Exit Sub
Else
Set rst = Nothing
End If
End Sub
My question is : When it exists i show a messagebox. But when I click OK in
that messagebox I want that my form (it is not a grid, but it show a record
by record) shows me the last inputed record and that the user must click
again on >* to add a record.
My seqond question: When you are entering a new record and you don't wont to
finishing it, how you can avoid that the record is inserted in the table? Or
how you can put it out of the table
Thanks,
jac