new to this form guys need some help

When opening a button and opening a new form as soon as it opens it close for some reason but its not giving any errors as to why its doing this
now i've checked the linked linking it to the next form thats fine but maybe someone could help me find a problem with this code ?

Private Sub PrintPerscription_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Login.con.Open()
sql = "SELECT Patient.* FROM Patient where Patient.Wardno = " & Login.WardNo.ToString
da = New OleDb.OleDbDataAdapter(sql, Login.con)
noOfRows = da.Fill(dsPatient, "Patient")

' add patients

For Me.count = 0 To noOfRows - 1
ComboBox1.Items.Add(dsPatient.Tables("Patient").Rows(count).Item(1))
Next
sql = "SELECT Drug.* From Drug "
da = New OleDb.OleDbDataAdapter(sql, Login.con)
result = da.Fill(dsDrug, "drug")

txtWardName.Text = Login.WardName
txtWardNo.Text = Login.WardNo

sql = "Select Prescriptions.* From Prescriptions"
da = New OleDb.OleDbDataAdapter(sql, Login.con)
result = da.Fill(dsPrescriptions, "Prescriptions")
Login.Close()
End Sub

Hi

What exactly is Login? If that is the name of your form then the line

Login.Close()

Is probably why your form closes.

Hi,

Probably the login form is your first form (form1).
That means that if you didn't changed the shutdown mode your application will shutdown completely.

The solution is: change the shutdown mode into 'when last form closes' and it will open the next form.

the program has 5 forms
login and then management from management you can pick 4 diffrent choices each taking you to other forms
i click the print prescription which is taking me to the form that when i open it it closes straight away

'Opens Print Prescription Form
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
PrintPerscription.Show()
Me.Hide()
End Sub

thats the code to take me to the prescription form

how do i change the shutdown mode

Ive got another problem when trying to record a prescription as soon as it opens it shows a error saying:


oldebException was unhandles
No value given for one or more required parameters.

code as is follows:

Private Sub Prescription_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox5.Text = DateTimePicker1.Value
Login.con.Open()
sql = "SELECT PatientName FROM Patient"
daPatient = New OleDb.OleDbDataAdapter(sql, Login.con)
Dim ds As New DataSet
noOfRows = daPatient.Fill(dsPatient, "Patient")

'add patient no to combo box
For Me.count = 0 To noOfRows - 1
cmbPatientName.Items.Add(dsPatient.Tables("Patient").Rows(count).Item(0))
Next

sql = "SELECT DrugName FROM Drug"
daDrug = New OleDb.OleDbDataAdapter(sql, Login.con)
Dim dsDrug As New DataSet
noOfRows = daDrug.Fill(dsDrug, "Drug")

'add drug code to combo box
For Me.count = 0 To noOfRows - 1
cmbDrugName.Items.Add(dsDrug.Tables("Drug").Rows(count).Item(0))
Next


Login.con.Close()
End Sub

This article has been dead for over six months. Start a new discussion instead.