Re: Opening a form to a specific record

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Since I am opening in the form in dialog mode, it seems to cancel any record
navigation or using the find method when the form opens. As a side note,
the form has an open event that sets some default values in the form based
on the user's configuration. Those are also bypassed.
I think I could get it to all work if I didn't use the dialog form, but then
I lose the ability to "pause" the rest of the code until I close the form.
I am open to suggestions.
Beth


"Keith Wilby" <here@xxxxxxxxx> wrote in message
news:44759bc9$1_1@xxxxxxxxxxxxxxxxxxxxxxxxx
"Beth" <Invalid@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:o6gdg.33147$4L1.3828@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a form, frmGrades, where I input student grades. The form has a
field listing each student by id number in a limited to list combo box.
When I type a student id in the box and that student isn't in the
database, I want to capture the id I just typed, add it to the students
table, and then open my students form (frmStudents) to the newly added
student's record so I can add their name, etc.
Right now I have code that captures the value and adds the student to the
students table, and it opens the students form, but I can't get to to go
to the new student's record.

So the new record is there but you just can't navigate to it? Have you
tried using the FindRecord method? You could pass the ID number to the
form in the OpenArgs.

HTH - Keith.
www.keithwilby.com

I have the form opening modal so that when the student form is closed and
you return to the main grades form, it runs a refresh and few other steps
for validating.
Below is a sample of the code up to the steps where I return from the
student form.

Can anyone tell me what I am doing wrong?
Thanks,
Beth


Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String

strMsg = "'" & NewData & "' is not a listed student. Click yes to add
this student."

If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Students", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!StudentID = NewData
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
DoCmd.OpenForm "frmStudents", , , "StudentID = NewData", ,
acDialog






.



Relevant Pages

  • RE: Open Excel file get error with file names that have spaces in
    ... files open fine in different windows, sometimes they open in the same window. ... Gary''s Student - gsnu200810 ... Result is that when I click on an Excel file, the program opens but the file ...
    (microsoft.public.excel.setup)
  • Re: Searching for and editing a record in form view
    ... I've created a query but I was a bit unsure of this, ... different from the StudentID for any other student. ... So I've done what you said, went to the switchboard, highlighted the combo ... This one opens the form to a specific record. ...
    (microsoft.public.access.forms)
  • Re: Opening a Binary file
    ... I have a routine which opens a binary file and reads its contents as ... Dim iFileNum As Integer ... Dim Student as STUDENT 'This is as UDT ... This function works fine if i pass an existing binary file name as the ...
    (microsoft.public.vb.controls)
  • Re: Searching for and editing a record in form view
    ... you want to select a student name on the ... I think the switchboard wizard option you used will go to a record ... Source of the combo box on the switchboard, you can create a query ... switchboard it opens the form for the required student. ...
    (microsoft.public.access.forms)
  • Opening a form to a specific record
    ... I have a form, frmGrades, where I input student grades. ... students table, and it opens the students form, but I can't get to to go to ... Dim rs As DAO.Recordset ...
    (microsoft.public.access.formscoding)