Hello all,
I got the following form;
With this form i can add observations to my excel sheet named "Observations".
With the following code the data is added to Observations.
Now i would like the same for Page 2 of the multipage. So i can add 2 observations at once.
For page 1 it works but how do I make it that when data is added to page 2 this data is entered beneath the data of page 1 in the sheet "observations"?
I got the following form;
With this form i can add observations to my excel sheet named "Observations".
With the following code the data is added to Observations.
VBA Code:
Private Sub cmdAddOberservation_Click()
Dim fTextBox As Object
Dim xEptTxtName As String
For Each fTextBox In Productionreturns.Controls
If TypeName(fTextBox) = "TextBox" Then
If fTextBox.Text = "" Then
xEptTxtName = xEptTxtName & fTextBox.Name & " is empty " & vbNewLine
End If
End If
Next
If xEptTxtName <> "" Then
MsgBox "The following required fields are not complete;" & vbNewLine & vbNewLine & Chr(13) & xEptTxtName, vbInformation
Exit Sub
Else
End If
If Worksheets("Observations").Range("A2").Value = "" Then
Worksheets("Observations").Range("A2:G2").FormulaArray = "1"
End If
Set Drng = Worksheets("Observations").Range("A1")
Drng.End(xlDown).Offset(1, 0).Value = Me.lblGelCodeR.Caption
Drng.End(xlDown).Offset(0, 1).Value = Me.lblProductNameR.Caption
Drng.End(xlDown).Offset(0, 2).Value = Me.lblBatchNumberR.Caption
Drng.End(xlDown).Offset(0, 3).Value = Me.lblBoxR.Caption
Drng.End(xlDown).Offset(0, 4).Value = Me.txtStDate.Value
Drng.End(xlDown).Offset(0, 5).Value = Me.txtCorrectBy.Value
Drng.End(xlDown).Offset(0, 6).Value = Me.txtEndDate.Value
Drng.End(xlDown).Offset(0, 7).Value = Me.txtCheckDate.Value
Drng.End(xlDown).Offset(0, 8).Value = Me.cboDocument.Value
Drng.End(xlDown).Offset(0, 9).Value = Me.cboDocumentPart.Value
Drng.End(xlDown).Offset(0, 10).Value = Me.cboPart.Value
Drng.End(xlDown).Offset(0, 11).Value = Drng.End(xlDown).Offset(-1, 8).Value + 1
Call MsgBox("A new observation has been added", vbInformation, "Add observation")
SortIt
Unload Me
On Error GoTo 0
Exit Sub
cmdAdd_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAddObservation_Click of Form Productionreturns"
End Sub
Now i would like the same for Page 2 of the multipage. So i can add 2 observations at once.
For page 1 it works but how do I make it that when data is added to page 2 this data is entered beneath the data of page 1 in the sheet "observations"?