DIVINEDAR0956
IS-IT--Management
I have the following function in Access and can't seem to understand why I'm getting an error that I don't understand. The function is as follows:
Public Function EditMarkupPercentage()
Dim rst As ADODB.Recordset
Dim i As Integer
Dim strTblName As String
Dim strNewFormulaValue As Variant
Dim strNewMTLValue As Variant
Dim strNewLBRValue As Variant
Dim strNewREPValue As Variant
Dim strNewNEGValue As Variant
Set rst = New ADODB.Recordset
strNewFormulaValue = InputBox("Enter New Formula GM or MU"
strNewMTLValue = InputBox("Enter New Material Percentage"
strNewLBRValue = InputBox("Enter New Labor Percentage"
strNewREPValue = InputBox("Enter New Rep Fee Percentage"
strNewNEGValue = InputBox("Enter New Negotiation Fee Percentage"
' DoCmd.OpenQuery "DltMarkupPercentage", acViewNormal, acEdit
For i = 1 To 500
strTblName = Choose(i, "Markup"
rst.Open "Select [FORMULA] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![FORMULA] = strNewFormulaValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [MTLMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![MTLMUP] = strNewMTLValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [LBRMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![LBRMUP] = strNewLBRValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [REPFEEMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![REPFEEMUP] = strNewREPValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [NEGOTFACTORMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![NEGOTFACTORMUP] = strNewNEGValue
rst.Update
rst.MoveNext
Wend
rst.Close
Next i
End Function
The error is "INVALID USE OF NULL" and I can't seem to make heads or tails of it.
It stops at this line "strTblName = Choose(i, "Markup"
". I checked the Markup table and I find no null spaces.
Could it be my "i" issue. There is only 43 records in the table and I have it checking up to 500. I not sure how that works yet either.
Someone please help. Darlene Sippio
dsippio@comtechsystems.com
Public Function EditMarkupPercentage()
Dim rst As ADODB.Recordset
Dim i As Integer
Dim strTblName As String
Dim strNewFormulaValue As Variant
Dim strNewMTLValue As Variant
Dim strNewLBRValue As Variant
Dim strNewREPValue As Variant
Dim strNewNEGValue As Variant
Set rst = New ADODB.Recordset
strNewFormulaValue = InputBox("Enter New Formula GM or MU"
strNewMTLValue = InputBox("Enter New Material Percentage"
strNewLBRValue = InputBox("Enter New Labor Percentage"
strNewREPValue = InputBox("Enter New Rep Fee Percentage"
strNewNEGValue = InputBox("Enter New Negotiation Fee Percentage"
' DoCmd.OpenQuery "DltMarkupPercentage", acViewNormal, acEdit
For i = 1 To 500
strTblName = Choose(i, "Markup"
rst.Open "Select [FORMULA] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![FORMULA] = strNewFormulaValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [MTLMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![MTLMUP] = strNewMTLValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [LBRMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![LBRMUP] = strNewLBRValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [REPFEEMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![REPFEEMUP] = strNewREPValue
rst.Update
rst.MoveNext
Wend
rst.Close
rst.Open "Select [NEGOTFACTORMUP] from " & strTblName & ";", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rst.EOF
rst![NEGOTFACTORMUP] = strNewNEGValue
rst.Update
rst.MoveNext
Wend
rst.Close
Next i
End Function
The error is "INVALID USE OF NULL" and I can't seem to make heads or tails of it.
It stops at this line "strTblName = Choose(i, "Markup"
Could it be my "i" issue. There is only 43 records in the table and I have it checking up to 500. I not sure how that works yet either.
Someone please help. Darlene Sippio
dsippio@comtechsystems.com