N
nxqviet
Hi all,
I have a question about using array that loop through a query and using
it to check againts a field on a form here is my code:
Dim Source As DAO.Recordset
Set Source = CurrentDb().OpenRecordset("qryArrayName")
Dim arName() As String
Dim intNameCount() As Integer
intNameCount = qryArrayName.RecordCount
ReDim arName(intNameCount )
Source.MoveFirst
Dim i As Integer
For i = 1 To Source.RecordCount
arName(i) = Source!PackageName
If FieldName.Value = arName(i) Then
MsgBox "This Name Already Existed, Please Use a
Different Name"
Exit Sub
End If
Source.MoveNext
Next i
AddDetail '<----This is another Sub that have other action.
Basically, I want the Code to check the value of the field and see if
it already existed or not. If yes, then promt a message, IF NOT, then
run the "AddDetail " Sub.
This code contains some error, But I can't figure it out. Please help.
thanks.
V_
I have a question about using array that loop through a query and using
it to check againts a field on a form here is my code:
Dim Source As DAO.Recordset
Set Source = CurrentDb().OpenRecordset("qryArrayName")
Dim arName() As String
Dim intNameCount() As Integer
intNameCount = qryArrayName.RecordCount
ReDim arName(intNameCount )
Source.MoveFirst
Dim i As Integer
For i = 1 To Source.RecordCount
arName(i) = Source!PackageName
If FieldName.Value = arName(i) Then
MsgBox "This Name Already Existed, Please Use a
Different Name"
Exit Sub
End If
Source.MoveNext
Next i
AddDetail '<----This is another Sub that have other action.
Basically, I want the Code to check the value of the field and see if
it already existed or not. If yes, then promt a message, IF NOT, then
run the "AddDetail " Sub.
This code contains some error, But I can't figure it out. Please help.
thanks.
V_