Macro Error Invalid Argument every other run

C

Carlos

I have a lovely piece of programming done by one of our MVPs here a couple
years back that was working great. After many modifications to keep it
current, it is now throwing an error every other run. These are all private
sub modules in a UserForm that execute when you push a button.

HERE IS THE PIECE THAT ERRORS
For i = 1 To lstSiteFields.ListCount
ffname = lstSiteFields.List(i - 1, 0)
If .Bookmarks.Exists(ffname) Then
If Not IsNull(lstSites.List(j, i - 1)) Then
.FormFields(ffname).Result =
lstSites.List(j, i - 1)
Else
.FormFields(ffname).Result = _
"Please enter data for " & ffname & "."
End If
End If
Next

This is the code link that errors - If Not IsNull(lstSites.List(j, i - 1))
Then

The first run it works great. I try to run it again on the document and it
fails. I have to close the form and reopen it to get it to work right.

"Could Not Get The List Property. Invalid Argument"

Thank you for your time,
Carlos
 
C

Carlos

Here are the Watch values

Watch : : i : 31 : Long : OCForm.cmdTransferDatatoDocument_Click
Watch : : j : 0 : Long : OCForm.cmdTransferDatatoDocument_Click
Watch : - : lstSites.List : : Variant/Variant(0 to 0, 0 to 15) :
OCForm.cmdTransferDatatoDocument_Click
- : lstSites.List(0) : : Variant(0 to 15) :
OCForm.cmdTransferDatatoDocument_Click
: lstSites.List(0,0) : 5077 : Variant/Long :
OCForm.cmdTransferDatatoDocument_Click
etc

If this can help someone answer this.
Thank you for your time,
Carlos
 
C

Carlos

OK- I am tracking this down- but still now answer

The property 1stSiteFields.ListCount seems to be doubling itself between
runs. I cannot figure the reason. One run it is 16 the next 32 using the
exact same SQL database, table, field, and record

Any Help?

Carlos
 
C

Carlos

OK- Solved it thanks to another post by Jean-Guy

This can all be replaced with:
cboTitle.Clear


The Form Lists needed to be cleared

lstSites.clear

Thanks for letting me work this in public

Carlos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top