Hi all i am try to pass the text input into the text boxes in form ( OrderScreen) into the text boxes in ( PrintOrderScreen)I don't get any error it just does not pass the text over to the second screen.

the text boxes with OS at the end belong to (OrderScreen : txtCustomerSurnameOS)

and the one without belong to Print order screen

Here is the code on print order screen:

Private Sub GetDetails()
        With frmOrderScreen
            txtCustomerSurname.Text = frmOrderScreen.txtCustomerSurnameOS.Text
            txtCustomerForename.Text = frmOrderScreen.txtCustomerForenameOS.Text
            txtCustomerAddress.Text = frmOrderScreen.txtCustomerAddressOS.Text
            txtCustomerTown.Text = frmOrderScreen.txtCustomerTownOs.Text
            txtCustomerPostcode.Text = frmOrderScreen.txtCustomerPostcodeOs.Text
            txtCustomerTeleNo.Text = frmOrderScreen.txtCustomerTeleNoOs.Text
        End With
    End Sub

This is the code on Order Screen ( also DataAccess is how i link to a database encase your wondering):

Public Sub SaveCustomerDbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveCustomerDbtn.Click
        Dim rep As Integer

        If txtCustomerSurnameOS.Text = "" Then
            rep = MsgBox("Please Input Surname", MsgBoxStyle.Critical)
            txtCustomerSurnameOS.Focus()
        Else
            If txtCustomerForenameOS.Text = "" Then
                rep = MsgBox("Please Input Forename", MsgBoxStyle.Critical)
                txtCustomerForenameOS.Focus()
            Else
                If txtCustomerAddressOS.Text = "" Then
                    rep = MsgBox("Please Input Address", MsgBoxStyle.Critical)
                    txtCustomerAddressOS.Focus()
                Else
                    If txtCustomerTownOs.Text = "" Then
                        rep = MsgBox("Please Input Town", MsgBoxStyle.Critical)
                        txtCustomerTownOs.Focus()
                    Else
                        If txtCustomerPostcodeOs.Text = "" Then
                            rep = MsgBox("Please Input Post Code", MsgBoxStyle.Critical)
                            txtCustomerPostcodeOs.Focus()
                        Else
                            If Not IsNumeric(txtCustomerTeleNoOs.Text) Then
                                rep = MsgBox("Please Input Telephone No", MsgBoxStyle.Critical)
                                txtCustomerTeleNoOs.Focus()
                            Else
                                dataAccess.CreateCustomer(txtCustomerSurnameOS.Text, txtCustomerForenameOS.Text, txtCustomerAddressOS.Text, txtCustomerTownOs.Text, txtCustomerPostcodeOs.Text, txtCustomerTeleNoOs.Text)
                                MsgBox("Customer saved", MsgBoxStyle.Information)
                                Me.Close()
                                frmPrintOrderScreen.Show()
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End Sub

I can't figure out what i am doing wron any help would be great

See if this helps.

Public Sub SaveCustomerDbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveCustomerDbtn.Click
        If txtCustomerSurnameOS.Text = "" Then
            MsgBox("Please Input Surname", MsgBoxStyle.Critical)
            txtCustomerSurnameOS.Focus()
            Exit Sub '// Skip remaining code.
        End If
        If txtCustomerForenameOS.Text = "" Then
            MsgBox("Please Input Forename", MsgBoxStyle.Critical)
            txtCustomerForenameOS.Focus()
            Exit Sub '// Skip remaining code.
        End If
        If txtCustomerAddressOS.Text = "" Then
            MsgBox("Please Input Address", MsgBoxStyle.Critical)
            txtCustomerAddressOS.Focus()
            Exit Sub '// Skip remaining code.
        End If
        If txtCustomerTownOs.Text = "" Then
            MsgBox("Please Input Town", MsgBoxStyle.Critical)
            txtCustomerTownOs.Focus()
            Exit Sub '// Skip remaining code.
        End If
        If txtCustomerPostcodeOs.Text = "" Then
            MsgBox("Please Input Post Code", MsgBoxStyle.Critical)
            txtCustomerPostcodeOs.Focus()
            Exit Sub '// Skip remaining code.
        End If
        If Not IsNumeric(txtCustomerTeleNoOs.Text) Then
            MsgBox("Please Input Telephone No", MsgBoxStyle.Critical)
            txtCustomerTeleNoOs.Focus()
            Exit Sub '// Skip remaining code.
        End If
        '// if all TextBoxes have values, then proceed.
        dataAccess.CreateCustomer(txtCustomerSurnameOS.Text, txtCustomerForenameOS.Text, txtCustomerAddressOS.Text, txtCustomerTownOs.Text, txtCustomerPostcodeOs.Text, txtCustomerTeleNoOs.Text)
        MsgBox("Customer saved", MsgBoxStyle.Information)
        Me.Close()
        frmPrintOrderScreen.Show()
    End Sub

See if this helps to figure out how Exit Sub works.

Public Class Form1
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Exit Sub."
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.Text = "Exit Sub." Then
            Me.Text = "Do not Exit Sub." '// set new text for testing when clicking Button again.
            Exit Sub '// skip the rest of the code within this Sub(Private Sub Button1_Click), in this case the code for the MsgBox.
        End If
        MsgBox("Sub was not Exited.")
    End Sub
End Class

You should use exit sub so the code that needs to be executed is not run if the data is not valid.

When you put all of your validating code at the top of the sub like codeorder did you can exit if there was bad data.

If you do not do it that way you will end up with if elseif elseif logic with your code to be executed in the last elseif.

Its easier to read when done like above, but you can do it any way you like.

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