CuriousMind1917
New Member
- Joined
- Jan 3, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I keep getting an error message every time I try to test the macro, after assigning it to a cell in my excel file.
This is what the error says: Run-Time Error '380' "Could not set the RowSource property. Invalid Property Value." I've included a screenshot of this message and a copy of my (borrowed) code below. The strange thing is that I get zero issues when I debug the code (Compile VBA Project). However, when I try to run the macro from my excel file after assigning it, I get the error message.
I am three days old in terms of VBA coding language.
The modified code basically has three parts: 1) For the form submit button (command) and the 2nd is for the reset command (button), the last one is to fill in the fields (textboxes) and to show the form once the macro is assigned. I hope I made sense.
Here is a copy of my modified (borrowed) code:
This is what the error says: Run-Time Error '380' "Could not set the RowSource property. Invalid Property Value." I've included a screenshot of this message and a copy of my (borrowed) code below. The strange thing is that I get zero issues when I debug the code (Compile VBA Project). However, when I try to run the macro from my excel file after assigning it, I get the error message.
I am three days old in terms of VBA coding language.
The modified code basically has three parts: 1) For the form submit button (command) and the 2nd is for the reset command (button), the last one is to fill in the fields (textboxes) and to show the form once the macro is assigned. I hope I made sense.
Here is a copy of my modified (borrowed) code:
VBA Code:
Option Explicit
Sub Reset()
Dim iRow As Long
iRow = [Counta(Database!A:A)] ' identifying the last row
With frmForm
.txtFSA.Value = ""
.txtCert.Value = ""
.txtPSU.Value = ""
.txtSelecDate.Value = ""
.txtFRCode.Value = ""
.txtGrade.Value = ""
.txtPay.Value = ""
.txtTrackOut.Value = ""
.txtTrackIN.Value = ""
.txtNHPDate = ""
.txtName.Value = ""
.txtLastName.Value = ""
.OptMale.Value = False
.OptFemale.Value = False
.txtDOB.Value = ""
.txtPhone.Value = ""
.txtEmail.Value = ""
.txtAddress.Value = ""
.txtCity.Value = ""
.txtZip.Value = ""
.txtState.Value = ""
.CmbSurvey.Clear
.CmbSurvey.AddItem "AHS"
.CmbSurvey.AddItem "CPS"
.CmbSurvey.AddItem "SIPP"
.CmbSurvey.AddItem "NIHS"
.LstDatabase.ColumnCount = 24
.LstDatabase.ColumnHeads = True
' .LstDatabase.ColumnWidths = "75 pt; 0pt"
If iRow > 1 Then
.LstDatabase.RowSource = "Database!A2:X" & iRow
Else
.LstDatabase.RowSource = "Database!A2:X2"
End If
End With
End Sub
Sub Submit()
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
iRow = [Counta(Database!A:A)] + 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = frmForm.CmbSurvey
.Cells(iRow, 3) = frmForm.txtFSA
.Cells(iRow, 4) = frmForm.txtCert
.Cells(iRow, 5) = frmForm.txtPSU
.Cells(iRow, 6) = frmForm.txtSelecDate
.Cells(iRow, 7) = frmForm.txtName
.Cells(iRow, 8) = frmForm.txtLastName
.Cells(iRow, 9) = IIf(frmForm.OptFemale.Value = True, "Female", "Male")
.Cells(iRow, 10) = frmForm.txtDOB
.Cells(iRow, 11) = frmForm.txtAddress
.Cells(iRow, 12) = frmForm.txtCity
.Cells(iRow, 13) = frmForm.txtZip
.Cells(iRow, 14) = frmForm.txtState
.Cells(iRow, 15) = frmForm.txtPhone
.Cells(iRow, 16) = frmForm.txtEmail
.Cells(iRow, 17) = frmForm.txtFRCode
.Cells(iRow, 18) = frmForm.txtGrade
.Cells(iRow, 19) = frmForm.txtPay
.Cells(iRow, 20) = frmForm.txtNHPDate
.Cells(iRow, 21) = frmForm.txtTrackOut
.Cells(iRow, 22) = frmForm.txtTrackIN
.Cells(iRow, 23) = Application.UserName
.Cells(iRow, 24) = [Text(Now(), "DD-MM-YYYY-HH:MM:SS")]
End With
End Sub
Sub Show_Form()
frmForm.Show
End Sub