Jim Lawrence
accessd at shaw.ca
Wed May 4 13:03:31 CDT 2005
Hi Penn: Would it be as simple as catching the error code and restarting the user at the place where If err.number = ???? cmbPersonID.setfocus msgbox "Please select a Person for this meeting First",vbinformation resume ... Or catch the error before it happens by checking whether any other entries can be made: If not isempty(cmbPersonID.value) If cmbPersonId > 0 ' Process meeting ... Else _display_message() endif Else _display_message() Endif HTH Jim -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Penn 227 Sent: Wednesday, May 04, 2005 9:45 AM To: Access Developers discussion and problem solving Subject: [AccessD] Fill in some fields in a new record without creating a new 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 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com