By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Help....Frustrated with Forms

P: n/a
Hello all.

Briefly described this is the problem I am having. I have a form, with
a related subform. On the subform I want to enter the expiration date
based on criteria in the main form. I have tried placing code in the
on exit event and the after update event with no luck. Please take a
look at the code and let me know what you think. Oh yeah..... I can
get this to work without using the main forms criteria ........ I
tried doing a Dlookup for this information dimming it as a variant etc
etc but no luck that route either.

On Error GoTo trapme94
Dim curcity As Long
Dim curcounty As Long
Dim appdt As Long
Dim juris As String
curcity = Forms!Permittools!Text256
curcounty = Forms!Permittools!Text258
appdt = Forms![tblPermitItem Subform]![Approval Date]
juris = Forms!Permittools!Jurisdiction & "'"

If juris Like "City" Then
Forms![tblPermitItem Subform]![Expiration Date] = appdt + curcity
Else

If juris Like "County" Then
Forms![tblPermitItem Subform]![Expiration Date] = appdt + curcounty

End If
End If

ExitExpDate:
Exit Sub
trapme94:
If Err.Number = 94 Then
Err = 0
Else

Resume ExitExpDate
End If

Thanks in advance!

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 24 Jul 2005 08:07:35 -0700, "Manystrengths"
<ma************@tampabay.rr.com> wrote:

I can't quite follow your code - I typically tune out quickly when I
see Text256, Text258 etc., but it appears you may have the syntax
wrong, as well as some data types.

dim dtApprovalDate as Date
dtApprovalDate = [Approval Date]
If you use Long instead, your code may fail or at least would not
behave as you expected.

If your code is in the parent form, this is how you access controls on
the subform:
dtApprovalDate = [tblPermitItem Subform].Form![Approval Date]
The way I think about it, without ".Form" you're talking about the
subform control itself, e.g.
[tblPermitItem Subform].Left = 200
With the ".Form" in place, you step into the subform and can now
access the form's properties and controls.

If your code is in the subform, this is syntax you can use:
dtApprovalDate = [Approval Date] 'a control on the subform
dim lngCityID as Long
lngCityID = Me.Parent.cboCity 'a combobox on the parent form.
Cool thing about ".Parent" is that this subform code will work
regardless of which parent it is on (as long as there is a cboCity on
it).

It appears you want to do date math. ALWAYS use the DateAdd function
for that.

-Tom.
Hello all.

Briefly described this is the problem I am having. I have a form, with
a related subform. On the subform I want to enter the expiration date
based on criteria in the main form. I have tried placing code in the
on exit event and the after update event with no luck. Please take a
look at the code and let me know what you think. Oh yeah..... I can
get this to work without using the main forms criteria ........ I
tried doing a Dlookup for this information dimming it as a variant etc
etc but no luck that route either.

On Error GoTo trapme94
Dim curcity As Long
Dim curcounty As Long
Dim appdt As Long
Dim juris As String
curcity = Forms!Permittools!Text256
curcounty = Forms!Permittools!Text258
appdt = Forms![tblPermitItem Subform]![Approval Date]
juris = Forms!Permittools!Jurisdiction & "'"

If juris Like "City" Then
Forms![tblPermitItem Subform]![Expiration Date] = appdt + curcity
Else

If juris Like "County" Then
Forms![tblPermitItem Subform]![Expiration Date] = appdt + curcounty

End If
End If

ExitExpDate:
Exit Sub
trapme94:
If Err.Number = 94 Then
Err = 0
Else

Resume ExitExpDate
End If

Thanks in advance!


Nov 13 '05 #2

P: n/a
Thanks tom. I'll give it a go........ I expected to meet with some
doubt when posting this code with textboxes named text. I impatiently
was trying to get this code to work so they were added to the form
quickly to look up the values to calculate the expiration date.
Hopefully I can get this to work.

Thanks again.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.