[AccessD] Fill in some fields in a new record withoutcreatinganew record?

Gustav Brock Gustav at cactus.dk
Wed May 4 12:53:13 CDT 2005


Hi Penn

Don't set the Value but - at the OnCurrent event when the ID is not
Null - the DefaultValue of those fields.
Then nothing is edited until the user types in something. After that
point pressing Escape is needed to cancel the new record.

/gustav

>>> penn227 at yahoo.com 05/04 7:40 pm >>>
Karen,

Thank you for the suggestion.  That would be fine if I
wanted to add a new 
record.  The problem really arises when I'm
accidentally in a new record (I 
hit the * button in the record selector) but don't
really want to add a new 
record.  If I attempt to move from that 'new empty'
record, I can't get out 
of it.  Delete Record doesn't work either because I'm
still in a 'new empty' 
record after the delete.

Penn


----- Original Message ----- 
From: "Nicholson, Karen" <cyx5 at cdc.gov>
To: "Access Developers discussion and problem solving"

<accessd at databaseadvisors.com>
Sent: Wednesday, May 04, 2005 1:22 PM
Subject: RE: [AccessD] Fill in some fields in a new
record without 
creatinganew record?


> Why don't you make the first statement something like:
>
> if isnull(me.person_id) then
> msgbox "You Must Select a Person",,"required entry"
> docmd.gotocontrol "person_id"
> exit sub
> end if
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Penn 227
> Sent: Wednesday, May 04, 2005 12:45 PM
> To: Access Developers discussion and problem solving
> Subject: [AccessD] Fill in some fields in a new record without
creating
> anew record?
>
> ACC03-WinXP Pro
>
> I'm at a loss with this problem and hope someone can help.
>
> I have a form in a 'members' database that allows entry of people
> (members, prospective members, guests, etc.) who have RSVP'd to an
> upcoming meeting.
> The Meeting info comes from tblMeetings (date, location, time, etc.)
and
> the person info comes from tblPeople.
>
> When a new record in frmRSVP is created, I would like to fill in some
of
> the fields in the new record (those that are starred below).
>
> The form consists of the following controls (not counting the
command
> buttons):
>
> ** ComboBox: MeetingID
> ** Text Box: MeetingDate
> ** Text Box: RSVPDue
> Option Group: ogShowRecords
> Option Button: optAll
> Option Button: optFuture
> Option Button: optPrevious
> Combo Box: PersonID
> Text Box: RSVPDate
> Text Box: Status
> Text Box: txtEmailAddress
> Text Box: Note
> Check Box: ReceiptConfSent
>
> The Form_Current sub looks like this:
>
> Private Sub Form_Current()
>  Dim intNewRec As Integer
>  Dim rsc As Recordset
> On Error GoTo Err_Form_Current
>    intNewRec = Me.NewRecord
>    If intNewRec Then
>        Set rsc = Me.RecordsetClone
>        Me.cboMeetingID = rsc!MeetingID
>        Me.MeetingDate = DLookup("MeetingDate", "tblMeetings",
> "MeetingID="
> & rsc!MeetingID)
>        Me.RSVPDue = DLookup("RSVPDue", "tblMeetings", "MeetingID=" &
> rsc!MeetingID)
>        Set rsc = Nothing
>        rsc.Clone
>        If (Now() > Me.RSVPDue) Then
>            Me.Late = True
>        End If
>    End If
>    Me.PersonID.SetFocus
> Exit_Form_Current:
>    Exit Sub
> Err_Form_Current:
>    ErrorHandler...
>    Resume Exit_Form_Current
> End Sub
>
> This works fine as long as there is actually someone selected in the
> PersonID control.  However, if it is blank, I get an error "The
> Microsoft Jet database engine can't find a record in the table
> "tblPeople" with key matching field(s) 'PersonID'. and I am thrown
into
> an endless loop trying to get out of that record with the empty
PeopleID
> control.
>
> Any help appreciated.
>
> Penn




More information about the AccessD mailing list