J
Jon22
Was hoping someone might help me. I have a subform in datasheet view in a
form. I have this code in the subform's Before Insert event (I'm new to VBA
so please be gentle with your response):
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![T Number] = Forms![Terms]![T Number]
Me![Order].Enabled = True
Me![Order] = Nz(DMax("[Order]", "[Term Subs]", "[T
Number]=Forms![Terms]![T Number]"), 0) + 1
Me![Order].Enabled = False
Forms![Terms].Refresh
End Sub
When this code refresh's it's parent form (I need this to happen for various
reasons), the character or letter that I type (which causes the Before Insert
code to run), gets highlighted (the Refresh command is the culprit - I
checked by removing it). That is, instead of the cursor being positioned
after this character happily blinking waiting for the next letter to be
typed, the original letter is highlighted and consequently replaced by the
second letter I type. I did a bit of investigating and thought that the
SelStart thingy might help and tried this code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![T Number] = Forms![Terms]![T Number]
Me![Order].Enabled = True
Me![Order] = Nz(DMax("[Order]", "[Term Subs]", "[T
Number]=Forms![Terms]![T Number]"), 0) + 1
Me![Order].Enabled = False
Forms![Terms].Refresh
Me![Title].SelStart = Me![Title].SelLength
End Sub
But still no luck. Does anyone have any suggestions? Thanks in advance.
form. I have this code in the subform's Before Insert event (I'm new to VBA
so please be gentle with your response):
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![T Number] = Forms![Terms]![T Number]
Me![Order].Enabled = True
Me![Order] = Nz(DMax("[Order]", "[Term Subs]", "[T
Number]=Forms![Terms]![T Number]"), 0) + 1
Me![Order].Enabled = False
Forms![Terms].Refresh
End Sub
When this code refresh's it's parent form (I need this to happen for various
reasons), the character or letter that I type (which causes the Before Insert
code to run), gets highlighted (the Refresh command is the culprit - I
checked by removing it). That is, instead of the cursor being positioned
after this character happily blinking waiting for the next letter to be
typed, the original letter is highlighted and consequently replaced by the
second letter I type. I did a bit of investigating and thought that the
SelStart thingy might help and tried this code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me![T Number] = Forms![Terms]![T Number]
Me![Order].Enabled = True
Me![Order] = Nz(DMax("[Order]", "[Term Subs]", "[T
Number]=Forms![Terms]![T Number]"), 0) + 1
Me![Order].Enabled = False
Forms![Terms].Refresh
Me![Title].SelStart = Me![Title].SelLength
End Sub
But still no luck. Does anyone have any suggestions? Thanks in advance.