R
Rick
Arvin:
Perhaps you have lost the thread on this discussion.
Rick
Subject: Re: Control data input
From: "Rick" <[email protected]> Sent: 1/21/2004 6:18:53
AM
Hello Arvin:
I finally got the following code to produce the required
result.
Private Sub Form_AfterUpdate()
If [Forms]![Contacts]![AddressTypes]!AddrTypeID > 3 And
[Forms]![Contacts]![AddressTypes]!CompanyID < 1 Then
MsgBox "You must enter a Company for this Address
Type", , "WBLI user input required"
Me.CompanyID.Visible = True
Me.CompanyID.SetFocus
End If
Forms!Contacts!AddressTypes!AddressDetails.SetFocus
Forms!Contacts!AddressTypes!AddressDetails!AddrTypeID
= HereSerial
Forms!Contacts!AddressTypes!AddressDetails!
CivicAddressLookup.SetFocus
End Sub
Function HereSerial()
Forms!Contacts!AddressTypes.SetFocus
HereSerial = Me.AddrID
End Function
However, I am still having difficulty in maintaining the
validation of data in the AddressDetails(subform2)
1. Once the user has entered an address type and a
company name (if applicable) in the AddressTypes
(subform1) the AfterUpdate event above correctly saves
the
record; writes the AddrTypeID in the detailed record from
the HereSerial variable; and moves the focus to the
CivicAddressLookup field. So far so good.
2. I have set the validation rule on the
CivicAddressLookup field to > 0 which prevents the user
from saving the detailed record without entering a valid
Civic address.
3. However; if the user presses escape they can move the
focus back to the AddressType field in the AddressTypes
(subform1) and move to the next record, effectively
saving
a record in the AddressTypes table without a
corresponding
record in the AddressDetails table.
What should happen when the user "opts out" of saving a
detailed record in subform2 with a valid civic address
the
focus should be set back on AddressTypes (subform1) and
the record automatically deleted. The user should not be
able to abort the deletion of the record but forced to
start the entire entry over from scratch.
Rick
subform2 and wite
Perhaps you have lost the thread on this discussion.
Rick
Subject: Re: Control data input
From: "Rick" <[email protected]> Sent: 1/21/2004 6:18:53
AM
Hello Arvin:
I finally got the following code to produce the required
result.
Private Sub Form_AfterUpdate()
If [Forms]![Contacts]![AddressTypes]!AddrTypeID > 3 And
[Forms]![Contacts]![AddressTypes]!CompanyID < 1 Then
MsgBox "You must enter a Company for this Address
Type", , "WBLI user input required"
Me.CompanyID.Visible = True
Me.CompanyID.SetFocus
End If
Forms!Contacts!AddressTypes!AddressDetails.SetFocus
Forms!Contacts!AddressTypes!AddressDetails!AddrTypeID
= HereSerial
Forms!Contacts!AddressTypes!AddressDetails!
CivicAddressLookup.SetFocus
End Sub
Function HereSerial()
Forms!Contacts!AddressTypes.SetFocus
HereSerial = Me.AddrID
End Function
However, I am still having difficulty in maintaining the
validation of data in the AddressDetails(subform2)
1. Once the user has entered an address type and a
company name (if applicable) in the AddressTypes
(subform1) the AfterUpdate event above correctly saves
the
record; writes the AddrTypeID in the detailed record from
the HereSerial variable; and moves the focus to the
CivicAddressLookup field. So far so good.
2. I have set the validation rule on the
CivicAddressLookup field to > 0 which prevents the user
from saving the detailed record without entering a valid
Civic address.
3. However; if the user presses escape they can move the
focus back to the AddressType field in the AddressTypes
(subform1) and move to the next record, effectively
saving
a record in the AddressTypes table without a
corresponding
record in the AddressDetails table.
What should happen when the user "opts out" of saving a
detailed record in subform2 with a valid civic address
the
focus should be set back on AddressTypes (subform1) and
the record automatically deleted. The user should not be
able to abort the deletion of the record but forced to
start the entire entry over from scratch.
Rick
on-----Original Message-----
Try this (untested):
Using the AfterUpdate event of Subform1, set the focus
subform2 and wite
..theAddrTypeID in:
Me.Parent.NameOfSubform2.Form.txtAddrTypeID =
Me.NameOfSubform1.txtAddrTypeID
Me.Parent.NameOfSubform2.Form.txtAddrTypeID.SetFocus
If it doesn't quite work that was, save the AddrTypeID from subform1 to a
variable, move the focus to subform2, then write it from the variable.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.561 / Virus Database: 353 - Release Date: 1/13/2004
.