G
grep
I'm having a number of problems with a General Procedure I'm trying to
write. I'm going to break up the problems, though, to make them easier
to handle - I hope.
The purpose of the procedure is to increment/decrement a form's date
field based on whether + or - is hit, like Quicken. I figured that the
way to get this done in a module that could be used on different forms,
would be to pass two arguments: The key (MyKey) and the actual name of
the field (DateField). Now, the call to this procedure is on the field's
OnKeyPress event, and it works fine, as long as I only have one
argument. As soon as I add the second argument, it tells me that the
expression is expecting an =. I don't know why.
The declaration is:
Public Sub DatePush(MyKey As Integer, DateField As String)
Now, the second problem has to do with the procedure itself. When I
originally coded this, in a form, it worked... sort of. I had to doctor
it some to get it working in a module. This is the code:
Dim CurrentDate As Date
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
CurrentDate = frmCurrentForm.DateField
Select Case MyKey
Case 45
frmCurrentForm.DateField = DateAdd("d", -1, CurrentDate)
Case 43
frmCurrentForm.DateField = DateAdd("d", 1, CurrentDate)
End Select
Now this works, sort of. It does increment/decrement the date properly.
The problem is that afterwards, it enters the +/- character into the
field, which doesn't work. I noticed, however, that if I hit the ESC
key, the +/- character is cancelled and the new incremented/decremented
date is now in place. I thought that I'd automate that, and get the
results I really want, by using SendKeys "{ESC}" at the end. But for
some reason, doing this throws it into some sort of loop state resulting
in a stack overflow.
The statement I actually used was:
SendKeys "{ESC}", True
Any help would be appreciated.
grep
write. I'm going to break up the problems, though, to make them easier
to handle - I hope.
The purpose of the procedure is to increment/decrement a form's date
field based on whether + or - is hit, like Quicken. I figured that the
way to get this done in a module that could be used on different forms,
would be to pass two arguments: The key (MyKey) and the actual name of
the field (DateField). Now, the call to this procedure is on the field's
OnKeyPress event, and it works fine, as long as I only have one
argument. As soon as I add the second argument, it tells me that the
expression is expecting an =. I don't know why.
The declaration is:
Public Sub DatePush(MyKey As Integer, DateField As String)
Now, the second problem has to do with the procedure itself. When I
originally coded this, in a form, it worked... sort of. I had to doctor
it some to get it working in a module. This is the code:
Dim CurrentDate As Date
Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
CurrentDate = frmCurrentForm.DateField
Select Case MyKey
Case 45
frmCurrentForm.DateField = DateAdd("d", -1, CurrentDate)
Case 43
frmCurrentForm.DateField = DateAdd("d", 1, CurrentDate)
End Select
Now this works, sort of. It does increment/decrement the date properly.
The problem is that afterwards, it enters the +/- character into the
field, which doesn't work. I noticed, however, that if I hit the ESC
key, the +/- character is cancelled and the new incremented/decremented
date is now in place. I thought that I'd automate that, and get the
results I really want, by using SendKeys "{ESC}" at the end. But for
some reason, doing this throws it into some sort of loop state resulting
in a stack overflow.
The statement I actually used was:
SendKeys "{ESC}", True
Any help would be appreciated.
grep