Open form from main form

foxtet

Registered User.
Local time
Tomorrow, 02:54
Joined
May 21, 2011
Messages
129
Im developing a small database to track patient records. i need to open add new patient form from the main form in blank mode with new patient ID.
any help can be very grateful.:)
 
Welcome to the forum.

Have a look at the OpenForm method, and use acFormAdd in the DataMode argument, this will allow the user to add new records but not edit or view existing records.
 
Thank you Jhon

when the add new patient command button is clicked, The patient information form should open in data entry mode with the patient ID text box must have a new value. that is last patient ID +1.
can you please give me coding to do this.
 
is there a way to attach the file? so that you can go through it
 
If you are using an Autonumber as your Patient ID this number will increment as soon as start entering data into the form.

Alternatively you could use the DMax() function plus one to assign your new patient ID. Check the sample posted here for a practical example.

To post a copy of your DB; you will get a better response if you are able to save your DB back to a version pre '07 (as not everyone has access to '07 or latter), next do a compact an repair on your DB, put your DB in a zip file. Now when you make your click the paper clip icon at the toip of the posting window and follow the bouncing ball from ther.
 
Thank you for prompt reply

pls analyse the attched file for a quick solution.. find the main frm and open it to see the main window. when you click the "open Form" button "frmNewPatient" window should open in data entry mode means all text boxes should be blank except the reference ID field. Reference ID should display the next referenceID. (ie the last RefID in tblPatientInfo+1)

any help is appreciated

fox:o:p
 
Last edited:
OK make the following (highlighted) addition to your Form frmNewPatient's On Current event;
Code:
Private Sub Form_Current()
If Me.NewRecord Then

    [B][COLOR="Red"]Me.ReferenceID = DMax("RefID", "tblPatientInfo") + 1
    
    Me.PatientIs.SetFocus[/COLOR][/B]
  
   Me.FirstName.Locked = False
   Me.LastName.Locked = False
   Me.Gender.Locked = False
   Me.IDCardNumber.Locked = False
   Me.DateOfBirth.Locked = False
      
   Me.EntryDate.Locked = False
   Me.EntryTime.Locked = False
        
Else
   
...

That should do the trick for you :o
 
Great....................

Thank you!!! SOOO much;
finally it worked...

By the way there is one more thing ti be done with "frmNewPatient" form. that is. when I add record and click save button the data doesn't display on the "frmMain" list box. Every time I have to close "frmMain" and re-open it to see the entered data. Is there a way for me to ge real time updating on "frmMain" list box when i click on the save button on "frmNewPatient"....


Fox
 
As part of the On Close event of form frmNewPatient you will need to force frmMain to requery;
Code:
Forms!Mainform.Requery
Should do the trick. Book mark this link for future reference for the correct syntax for referencing form/subforms their controls and properties from various relative locations.
 
Thank you;

there is no response;;;; I mean the list box in the frmMain does not get updated when clicked close button on frmNewPatient...any more idea pls hlp

Fox
 
Sorry my bad :o try;
Code:
Forms!frmmain!SearchResults.Requery
instead, that should do the trick.
 
Thank you very much..
it worked. fine you are very helpful...

fox
 
If you have a copy of the .mdb file (the one I attached). can you work on the following;

from frmMain click Open form button to open frmNewPatient.

Now suppose if the user wants to close the form without filling any records, there gets a message "The feild "tblPatientInfo.FirstName cannot contain Null value because the required property for this field is set to True. Enter a value in this field" when user clicks OK button again there is another msg "You can't save this record at this time"...

These messages can confuse the user hence I want even if user close the form without filling it he should not get error msg.. any ideas

fox
 
One way to over come this problem, would be to set all fields currently flagged as Required in your table tblPatientInfo to Not Required. Also set the forms Control Box property to No.

Now put a new button on your form, let's set it's caption to Close, in this buttons On Click event put the following code;
Code:
    Dim msgResponse As String
    
    If Me.NewRecord Then
        If IsNull(Me.FirstName) And IsNull(Me.PatientIs) And IsNull(Me.Gender) And IsNull(Me.InsuranceCompany) Then
            Me.Undo
            DoCmd.Close acForm, "frmNewPatient"
        ElseIf IsNull(Me.FirstName) Or IsNull(Me.PatientIs) Or IsNull(Me.Gender) Or IsNull(Me.InsuranceCompany) Then
            MsgBox "There is missing missing Data " & _
            "All field indicated by a red astrisk must " & _
            "Be completed"
            
            msgResponse = MsgBox("If you wish to save this record click YES and provide the missing data " & _
            "Otherwise click NO to clear the form and cancel", vbYesNo)
            
            If msgResponse = vbYes Then
                Cancel = True
                Exit Sub
            Else
                Me.Undo
                DoCmd.Close acForm, "frmNewPatient"
            End If
        End If
      DoCmd.Close acForm, "frmNewPatient"
       
    End If
I think that should do the trick.
 
You have found the exact solution for the error msg that I have explained.. Thank you soooo much. You guys are great in building logics. Thank you

I am here attaching you a new copy of the database file for you to work on the logic that I have found very difficult to solve.

When patients come for consultation each patient will be given a token number from a doctor they wish.

Now when you double click a patient name from the search list box in the frmMain frmPatient window opens in that window there is a button called “Generate Memo in this memo window there is doctor’s combo box to select doctor.

Now when you select doctor the token number for that doctor should display the text box given there. Token number text box should be editable so that user can put any number for a given doctor after that it should count next number. I have tried to build logic for this still I am unable to do this.

Can you pls bring necessary changers to table structure and build this logic
Your help is highly appreciated
 
Last edited:

Users who are viewing this thread

Back
Top Bottom