Hello --
New to the forum and fairly new to vba. I am running a for loop with a run sql command as part of it. It runs correctly the first time, updates the proper table and populates the form. When it comes back again, the value of the counter (i) is correctly incremented, but the sql statement doesn't run. I do NOT get an error message, it just sort of hangs. I check to see if the table are open, thinking that might be it (they are not) so can't figure what I am missing. The msgboxes are simply to check values and let me see where the problem may be. DeleteRecordsSQL function merely deletes the old records in the target table before adding the new ones.
partial code:
For i = 1 To splits
MsgBox "Value of i in Splits =: " & i
DeleteRecordsSQL
strSQL = "SELECT SplitTable.FirstName, SplitTable.lastName, SplitTable.School INTO SparTable FROM SplitTable WHERE splitTable.Split = " & i & ""
IsObjectOpen ("SparTable")
IsObjectOpen ("SplitTable")
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
MsgBox "SparTable updated"
Set rsteventsplit = dbsTournament.OpenRecordset("SparTable")
MsgBox "passing value of i - number of splits -- to cmdpopulategrid function: " & i
DoCmd.OpenForm "SparringSplits", acNormal
cmdPopulateGrid (i)
Next
On Error GoTo Error_Handler
Dim Rpt As Report
Error_Handler_Exit:
On Error Resume Next
Set Rpt = Nothing
Exit Sub
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
" Error Number: " & Err.Number & vbCrLf & _
" Error Source: RedefRptSQL" & vbCrLf & _
" Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
(END partial Code)
Any help is appreciated
New to the forum and fairly new to vba. I am running a for loop with a run sql command as part of it. It runs correctly the first time, updates the proper table and populates the form. When it comes back again, the value of the counter (i) is correctly incremented, but the sql statement doesn't run. I do NOT get an error message, it just sort of hangs. I check to see if the table are open, thinking that might be it (they are not) so can't figure what I am missing. The msgboxes are simply to check values and let me see where the problem may be. DeleteRecordsSQL function merely deletes the old records in the target table before adding the new ones.
partial code:
For i = 1 To splits
MsgBox "Value of i in Splits =: " & i
DeleteRecordsSQL
strSQL = "SELECT SplitTable.FirstName, SplitTable.lastName, SplitTable.School INTO SparTable FROM SplitTable WHERE splitTable.Split = " & i & ""
IsObjectOpen ("SparTable")
IsObjectOpen ("SplitTable")
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
MsgBox "SparTable updated"
Set rsteventsplit = dbsTournament.OpenRecordset("SparTable")
MsgBox "passing value of i - number of splits -- to cmdpopulategrid function: " & i
DoCmd.OpenForm "SparringSplits", acNormal
cmdPopulateGrid (i)
Next
On Error GoTo Error_Handler
Dim Rpt As Report
Error_Handler_Exit:
On Error Resume Next
Set Rpt = Nothing
Exit Sub
Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
" Error Number: " & Err.Number & vbCrLf & _
" Error Source: RedefRptSQL" & vbCrLf & _
" Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
(END partial Code)
Any help is appreciated