By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

Invalid use of Property?!?! ><

P: 13
I'm writing some very simple codes that i'm quite sure are correct (at least i can't find out what is wrong with it =P)

I'm trying to run the following:

-------------------------------------------------------------------------------------------------------------

Private Sub CSV_Click()

Call CSV(Forms![ValMainScreen].[vdate].Value)

End Sub

-------------------------------------------------------------------------------------------------------------

Sub CSV(valdate As Date)

Dim rst_p, rst_r, rst_table, rst_master As DAO.Recordset
Set db = CurrentDb
Set rst_p = db.OpenRecordset("Pol", dbOpenTable)
Set rst_r = db.OpenRecordset("Rid", dbOpenTable)
rst_p.Index = "PrimaryKey"
rst_r.Index = "PrimaryKey"
rst_r.MoveFirst
rst_p.MoveFirst.......etc.

-------------------------------------------------------------------------------------------------------------

When I tried to run "Call CSV", a msgbox pops up and says "Invalid use of Property".

I have used this format to call functions and subs I don't know why it's not working this time...

Can someone tell me what has gone wrong?

Thank you!!
Nov 10 '08 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello.

You should do more investigation and localize code error source.
  • Is it reference to form control?
  • Is it control value which may be Null or couldn't be recognized as Date type value?
  • Is it code in CSV() subroutine?
  • Do you have a missing reference to external library?
  • Is it something else?

Regards,
Fish.
Nov 10 '08 #2

ADezii
Expert 5K+
P: 8,597
Your code seems to need some revisions as I will indicate below. Do the Tables Pol and Rid actually exist with Primary Keys defined as 'PrimaryKey' (the Default)?:
Expand|Select|Wrap|Line Numbers
  1. Public Sub CSV(valDate As Variant)
  2. Dim dtePassedDate As Date
  3. Dim db As DAO.Database
  4. Dim rst_p As DAO.Recordset
  5. Dim rst_r As DAO.Recordset
  6. Dim rst_table As DAO.Recordset
  7. Dim rst_master As DAO.Recordset
  8.  
  9. 'You must consider the possibility that valDate may either be
  10. 'NULL or not even a Date at all
  11. If IsNull(valDate) Or Not IsDate(valDate) Then Exit Sub
  12.  
  13. 'Make it explicit
  14. dtePassedDate = CDate(valDate)
  15.  
  16. Set db = CurrentDb()
  17.  
  18. Set rst_p = db.OpenRecordset("Pol", dbOpenTable)
  19. Set rst_r = db.OpenRecordset("Rid", dbOpenTable)
  20.  
  21. rst_p.Index = "PrimaryKey"
  22. rst_r.Index = "PrimaryKey"
  23.  
  24. rst_r.MoveFirst
  25. rst_p.MoveFirst
  26.  
  27. '...etc., etc., etc., Blah, Blah, Blah
  28.  
  29. 'Test
  30. Debug.Print rst_r.Fields(2)
  31. Debug.Print rst_p.Fields(3)
  32.  
  33. rst_p.Close
  34. rst_r.Close
  35. Set rst_p = Nothing
  36. Set rst_r = Nothing
  37.  
  38. 'Errors will generate here because of rst_table
  39. 'and rst_master not being initialized, that's
  40. 'why the On Error Resume Next Statement
  41. On Error Resume Next
  42. rst_table.Close
  43. rst_master.Close
  44. Set rst_table = Nothing
  45. Set rst_master = Nothing
  46. End Sub
Nov 10 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.