Run-Time Error '380' When testing the macro in VBA Excel (Rowsource Property issue)

CuriousMind1917

New Member
Joined
Jan 3, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. 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:
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
 

Attachments

  • Error message.PNG
    Error message.PNG
    5.7 KB · Views: 29

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Sorry, I forgot to mention that the error leads to this specific line being highlighted in yellow:
Sub Show_Form()


Rich (BB code):
frmForm.Show

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top