I
Irshad Alam
I have written the following codes on my suform first field onGotFocus Event,
to get the Auto increment number on the subform. It works fine when there is
data in the subform, I mean the movement of the curson is normal, but when
there is no data on the subform, I mean when I enter data to a new record,
the cursor does not stop on the subform and it moves to a field after the
subform control. I could not understand, that when there is data, it moves
correct accordingly as set in Tab Order and generates increment number. But
why does it not work when the subform has no data.
To solve the problem for the time being, I have asked the User to press
DownArrow Key, so that it can come back to subform. Or By mouse, put the
cursor on the first field of subform.
The thing to be noted is that , when I/User move by mouse or by back arrow
key, it generates the number correct, I mean, it calculates 1.
Just because of a cursor movement problem, I am unable to complete the form.
Please check the code which I have written and advise, where to correct :
Private Sub Ino_GotFocus()
Dim GetNo As Integer
Cancel = True
If [Forms]![TotFormA]![TotFormB]![Desc2] = "" Or
IsNull([Forms]![TotFormA]![TotFormB]![Desc2]) Then
GetNo = IIf(DCount("[Desc2]", "[TotTabB]",
"[FormNo]=[Forms]![TotFormA]![FormNo]") = "", "0", DCount("[Desc2]",
"[TotTabB]", "[FormNo]=[Forms]![TotFormA]![FormNo]"))
[Forms]![TotFormA]![TotFormB]![Ino] = GetNo + 1
End If
End Sub
I removed the line :
Cancel = True
Then also same problem.
Please advise me in details about the method to overcome this problem.
to get the Auto increment number on the subform. It works fine when there is
data in the subform, I mean the movement of the curson is normal, but when
there is no data on the subform, I mean when I enter data to a new record,
the cursor does not stop on the subform and it moves to a field after the
subform control. I could not understand, that when there is data, it moves
correct accordingly as set in Tab Order and generates increment number. But
why does it not work when the subform has no data.
To solve the problem for the time being, I have asked the User to press
DownArrow Key, so that it can come back to subform. Or By mouse, put the
cursor on the first field of subform.
The thing to be noted is that , when I/User move by mouse or by back arrow
key, it generates the number correct, I mean, it calculates 1.
Just because of a cursor movement problem, I am unable to complete the form.
Please check the code which I have written and advise, where to correct :
Private Sub Ino_GotFocus()
Dim GetNo As Integer
Cancel = True
If [Forms]![TotFormA]![TotFormB]![Desc2] = "" Or
IsNull([Forms]![TotFormA]![TotFormB]![Desc2]) Then
GetNo = IIf(DCount("[Desc2]", "[TotTabB]",
"[FormNo]=[Forms]![TotFormA]![FormNo]") = "", "0", DCount("[Desc2]",
"[TotTabB]", "[FormNo]=[Forms]![TotFormA]![FormNo]"))
[Forms]![TotFormA]![TotFormB]![Ino] = GetNo + 1
End If
End Sub
I removed the line :
Cancel = True
Then also same problem.
Please advise me in details about the method to overcome this problem.