S
Shailesh
Dear Friends
I have written the following codes to update the table Cntry.
Private Sub Form_AfterUpdate()
Dim conDatabase As ADODB.Connection
Dim strSQL As String
Dim CNTR As Integer
Dim CNTRSQL As String
Set conDatabase = CurrentProject.Connection
'Set conDatabase = CurrentDb
strSQL = "insert into cntryview values(" & Chr(34) & Me.Country_O &
Chr(34) & ")"
CNTRSQL = "SELECT count(COUNTRY) as num FROM CNTRY WHERE COUNTRY =" &
Chr(34) & Me.Country_O & Chr(34) & " "
conDatabase.Execute CNTRSQL
'Set rstEmployees = New Recordset
'rstEmployees.Open strSQL, conDatabase, adOpenDynamic, adLockOptimistic
conDatabase.Execute strSQL
MsgBox "data inserted"
conDatabase.Close
Set conDatabase = Nothing
End Sub
Can you please suggest how can i modify the above code so that it would
check for the value in the table and if the same value is not there then
only it would update the table.
YOur guidance will help me to solve the problem.
Thanks and best regards
Shailesh
I have written the following codes to update the table Cntry.
Private Sub Form_AfterUpdate()
Dim conDatabase As ADODB.Connection
Dim strSQL As String
Dim CNTR As Integer
Dim CNTRSQL As String
Set conDatabase = CurrentProject.Connection
'Set conDatabase = CurrentDb
strSQL = "insert into cntryview values(" & Chr(34) & Me.Country_O &
Chr(34) & ")"
CNTRSQL = "SELECT count(COUNTRY) as num FROM CNTRY WHERE COUNTRY =" &
Chr(34) & Me.Country_O & Chr(34) & " "
conDatabase.Execute CNTRSQL
'Set rstEmployees = New Recordset
'rstEmployees.Open strSQL, conDatabase, adOpenDynamic, adLockOptimistic
conDatabase.Execute strSQL
MsgBox "data inserted"
conDatabase.Close
Set conDatabase = Nothing
End Sub
Can you please suggest how can i modify the above code so that it would
check for the value in the table and if the same value is not there then
only it would update the table.
YOur guidance will help me to solve the problem.
Thanks and best regards
Shailesh