Ok, I'm trying to figure out what code I need to change to make this work and
am having problems working with the help menus to determine what needs to
adjust in my code to make this work with an ODBC database table. Can you
help (below is my program)??
Option Compare Database
Dim dbs As Database
Dim Table As String
Dim EndDate As Date
Dim rst As Recordset
Dim CalendarDate As Date
Dim MinSerial As String
Dim MaxSerial As String
Dim Override As String
Dim strmessage As String
Function InsertRangeRecords()
Set dbs = CurrentDb
'User Input
On Error GoTo TableInputError
Table = InputBox("Enter the Serial Range Table Name You Want To Add
Records To:", "Table")
Set rst = dbs.OpenRecordset(Table, dbOpenDynaset)
On Error GoTo 0
EndDate = InputBox("Enter the Ending Calendar Date You Want To Finish
With (mm/dd/yy):", "Calendar Date")
'Get values from last record in the table
With rst
.MoveLast
CalendarDate = CLM_RECEIVED_DT!
MinSerial = MIN_SERIAL_NBR!
MaxSerial = MAX_SERIAL_NBR!
Override = OVERRIDE_FLAG!
End With
'Loop to do the insertion of records to the ending calendar date inputted
Do Until CalendarDate = EndDate
CalendarDate = CalendarDate + 1
With rst
.AddNew
![CLM_RECEIVED_DT] = CalendarDate
![MIN_SERIAL_NBR] = MinSerial
![MAX_SERIAL_NBR] = MaxSerial
![OVERRIDE_FLAG] = Override
End With
Loop
rst.Close
TableInputError:
strmessage = MsgBox("You have entered an invalid table name. Please restart
the program.", vbOKOnly)
End Function
buzz said:
Is there a limitation with the rst.OpenRecordset command when using linked
ODBC databases?? I'm trying to run commands to get data from the last record
of a table from an IBM DB2 database (opening this table requires the user to
enter login information). If I do the exact same commands to a local Access
table, it works just fine. Is there a know problem with this and what about
a workaround??