maxmangion
AWF VIP
- Local time
- Today, 22:13
- Joined
- Feb 26, 2003
- Messages
- 2,805
on a form i have a control (textbox), in which i enter positive integers only. Now sometimes i need to add this integer so i created a public sub with the following code:
The above code works fine, except when the field is null. If the field is blank nothing happens. Eventually, i tried to include the following code instead of the simple line:
With this newly added code i am getting an error 424 object required.
I have also tried putting the following:
this last statement will still still give me the error 424, however, after clicking ok i will get the correct result (but since i am getting the error message before, i believe i have something wrong).
Thank you for any suggestions.
Code:
Public Sub AddStamps()
On Error GoTo Err_AddStamps
Dim frm As Form
Dim ctl As Control
Dim amount As Integer
Set frm = Screen.ActiveForm
Set ctl = Screen.ActiveControl
amount = InputBox("Enter the Amount you wish to add", "Add Stamps")
ctl = ctl + amount
Exit_AddStamps:
Exit Sub
Err_AddStamps:
MsgBox Err.Description, vbExclamation, Err.Number
Resume Next
End Sub
The above code works fine, except when the field is null. If the field is blank nothing happens. Eventually, i tried to include the following code instead of the simple line:
Code:
If ctl Is Not Null Then
ctl = ctl + amount
Else
ctl = amount
End If
With this newly added code i am getting an error 424 object required.
I have also tried putting the following:
Code:
If ctl is null then
ctl = 0
end if
this last statement will still still give me the error 424, however, after clicking ok i will get the correct result (but since i am getting the error message before, i believe i have something wrong).
Thank you for any suggestions.