Hi Group:
I've been messing with this for WAY too long! All I want to do is copy records from one table to another using code.
I would like to copy records from tblContact to tblNew. The code below will also use a active X progress meter. Sombody PLEASE HELP, I'm sick of playing with this!!!!!
This is what I have so far:
Dim dbs As Database
Dim stContacts As Recordset
Dim intRet As Integer
Dim rstNew As Recordset
Dim tblNew As Recordset
Dim intCount As Integer
Dim strQuery As String
Dim sngPercent As Single
Dim varReturn As Variant
Dim lngEmpID() As Long
Dim CountRecords As Variant
On Error GoTo ErrorHandler
strQuery = "SELECT tblContact.* FROM tblContact;"
intCount = 0
Set dbs = CurrentDb
Set rstContacts = dbs.OpenRecordset(strQuery, dbOpenDynaset)
Set rstNew = tblNew
CountRecords = DCount("[Record]", "tblContact"
prgTest.BarStyle = tacmPrgSolid
prgTest.Max = CountRecords
Me.Start = Now()
DoEvents
With rstContacts
If .EOF Then ' If no records, exit.
Exit Function
Else
intRet = prgTest
End If
Do Until .EOF
If !Record >= 1 Then
.AddNew
****What goes here???????????????
.Update
End If
If .PercentPosition <> 0 Then
intCount = intCount + 1
prgTest.Value = intCount
End If
.MoveNext
Loop
.Close
Me.End = Now()
Me.prgTest.Visible = False
End With
ErrorHandler:
Select Case Err
Case 0
Exit Function
Case Else
MsgBox "Error " & Err & ": " & Error, vbOKOnly, "ERROR"
Exit Function
End Select
End Function
I've been messing with this for WAY too long! All I want to do is copy records from one table to another using code.
I would like to copy records from tblContact to tblNew. The code below will also use a active X progress meter. Sombody PLEASE HELP, I'm sick of playing with this!!!!!
This is what I have so far:
Dim dbs As Database
Dim stContacts As Recordset
Dim intRet As Integer
Dim rstNew As Recordset
Dim tblNew As Recordset
Dim intCount As Integer
Dim strQuery As String
Dim sngPercent As Single
Dim varReturn As Variant
Dim lngEmpID() As Long
Dim CountRecords As Variant
On Error GoTo ErrorHandler
strQuery = "SELECT tblContact.* FROM tblContact;"
intCount = 0
Set dbs = CurrentDb
Set rstContacts = dbs.OpenRecordset(strQuery, dbOpenDynaset)
Set rstNew = tblNew
CountRecords = DCount("[Record]", "tblContact"
prgTest.BarStyle = tacmPrgSolid
prgTest.Max = CountRecords
Me.Start = Now()
DoEvents
With rstContacts
If .EOF Then ' If no records, exit.
Exit Function
Else
intRet = prgTest
End If
Do Until .EOF
If !Record >= 1 Then
.AddNew
****What goes here???????????????
.Update
End If
If .PercentPosition <> 0 Then
intCount = intCount + 1
prgTest.Value = intCount
End If
.MoveNext
Loop
.Close
Me.End = Now()
Me.prgTest.Visible = False
End With
ErrorHandler:
Select Case Err
Case 0
Exit Function
Case Else
MsgBox "Error " & Err & ": " & Error, vbOKOnly, "ERROR"
Exit Function
End Select
End Function