form view to data sheet view

C

Cynthia

I have code that updates a number if there are any changes on 3 other fields.
I need to be able to use this in data sheet view so we can copy multiple
items.
I can copy one item at a time and all is fine. But if I select more than
one item to copy I get a time out error on
If IsNull (Dmax ("[Num]", "qryLookUpArea", strQry)) line of code. I have
the code below. Any ideas on how to get this to work in datasheet view? I
am calling this function from the after update of the form.

Private Function CreateEleLineNum()
Dim strVolt As String
Dim strType As String
Dim strArea As String
Dim strSql As String
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim strnum3 As String
Dim strLineNo As String
gNewNum = 0
DoCmd.SetWarnings False

strVolt = CmbVL.Column(0)
strType = CmbType.Column(0)
strArea = CmbArea
num1 = CmbArea.Column(1)
num2 = CmbArea.Column(2)
strQry = "[Num] >= " & num1 & " AND [Num] < " & num2 & _
" AND [Volt] = '" & strVolt & "' AND [Type] = '" & strType & "'"
If IsNull(DMax("[Num]", "qryLookUpArea", strQry)) Then
strnum3 = num1 + 1
Else
strnum3 = DMax("[Num]", "qryLookUpArea", strQry) + 1
End If
strnum3 = strnum3
While Len(strnum3) < 4
strnum3 = "0" & strnum3
Wend

LnNo.Value = strType & "-" & strnum3 '& "-" & strVolt TOOK VOLT OUT OF TAG

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top