B
Bill
In the code below, I seem to be caught in some sort of
timing problem. Does the Currentdb.Execute need
some sort of additional parameters so that it completes
before the next record in rsAHSAddrlst is processed?
As it is, not all records processed are reflected in the
final output. Those that are came out fine, but there's
several missing.
***********************************************************************
Option Explicit
Public Sub AddAHS()
Dim con As ADODB.Connection
Dim rsAHSAddrlst As ADODB.Recordset
Dim strSQL As String
'==========================================================================================
'Open our temporary holding table for the AHS folks.
'==========================================================================================
Set con = Application.CurrentProject.Connection
Set rsAHSAddrlst = New ADODB.Recordset
rsAHSAddrlst.Open "SELECT * FROM [AHSAddrlst]", con, adOpenKeyset,
adLockOptimistic
While (Not (rsAHSAddrlst.EOF))
'==========================================================================================
'Okay, add the current individual to our general address list table.
'==========================================================================================
strSQL = "INSERT INTO [addrlst]
(LastName,FirstName,EmailHome,CityState,Hornet)"
strSQL = strSQL & " VALUES(" & Chr(34) & rsAHSAddrlst![LastName] &
Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![FirstName] & Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![EmailHome] & Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![CityState] & Chr(34) & ","
strSQL = strSQL & True & ");"
CurrentDb.Execute strSQL
rsAHSAddrlst.MoveNext
Wend
'Close the StatsKey recordset.
rsAHSAddrlst.Close
Set rsAHSAddrlst = Nothing
Set con = Nothing
End Sub
timing problem. Does the Currentdb.Execute need
some sort of additional parameters so that it completes
before the next record in rsAHSAddrlst is processed?
As it is, not all records processed are reflected in the
final output. Those that are came out fine, but there's
several missing.
***********************************************************************
Option Explicit
Public Sub AddAHS()
Dim con As ADODB.Connection
Dim rsAHSAddrlst As ADODB.Recordset
Dim strSQL As String
'==========================================================================================
'Open our temporary holding table for the AHS folks.
'==========================================================================================
Set con = Application.CurrentProject.Connection
Set rsAHSAddrlst = New ADODB.Recordset
rsAHSAddrlst.Open "SELECT * FROM [AHSAddrlst]", con, adOpenKeyset,
adLockOptimistic
While (Not (rsAHSAddrlst.EOF))
'==========================================================================================
'Okay, add the current individual to our general address list table.
'==========================================================================================
strSQL = "INSERT INTO [addrlst]
(LastName,FirstName,EmailHome,CityState,Hornet)"
strSQL = strSQL & " VALUES(" & Chr(34) & rsAHSAddrlst![LastName] &
Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![FirstName] & Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![EmailHome] & Chr(34) & ","
strSQL = strSQL & Chr(34) & rsAHSAddrlst![CityState] & Chr(34) & ","
strSQL = strSQL & True & ");"
CurrentDb.Execute strSQL
rsAHSAddrlst.MoveNext
Wend
'Close the StatsKey recordset.
rsAHSAddrlst.Close
Set rsAHSAddrlst = Nothing
Set con = Nothing
End Sub