Reputation: 26
It's probably something simple but I have been trying to work out how to fix a compile error I am getting with an excel document I have created for a while now and I have not made any progress.
Basically there is a form that has several buttons that call a public function called "writeEntry
" which is stored in a module called "describePhotosExcel
".
The code does this syntax error at the line test = writeEntry(wrow, ..., Condition.Text)
, no matter where writeEntry
is called from:
Compile Error - Expected function or variable
So far I have tried calling the function from different subs, changing the subs from private to public, adding the module name before the function and renaming the function... I'm not quite sure what else I can do. Any help would be much appreciated.
Code from the form:
Private Sub PrevPhotoBTN_Click()
wrow = CInt(PhotoDataEntry.CurrentRow.Caption)
test = writeEntry(wrow, Direction.Text, RoadCombo.Text, Chainage.Text, Location.Text, CommentsCombo.Text, Condition.Text)
wrow = CInt(PhotoDataEntry.CurrentRow.Caption) - 1
PhotoDataEntry.CurrentRow.Caption = wrow
temp = PopulatePhotoForm()
End Sub
Code from the module "describePhotosExcel":
Public Function writeEntry(CurrentRow, Dir, RoadName, Chainage, Optional Title = "", Optional Comments = "", Optional Rating = "", Optional PhotoNumber = "") As Variant
Application.Workbooks(PhotoDataEntry.WBK.Caption).Activate
Worksheets("Data").Activate
Cells(CurrentRow, 6) = Dir
Cells(CurrentRow, 8) = RoadName
Cells(CurrentRow, 9) = Chainage
Cells(CurrentRow, 10) = Title
Cells(CurrentRow, 11) = Comments
Cells(CurrentRow, 14) = Rating
Cells(CurrentRow, 13) = PhotoNumber
writeEntry = 1
End Function
Upvotes: 0
Views: 801
Reputation: 26
So I worked it out.
I had created a subroutine called "test" which was used to do some testing. Therefore when it saw the word test it thought I was referring to this subroutine and not a new variable I was throwing away. Deleted that and it works well now.
Upvotes: 0