473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Invalid use of Property?!?! ><

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
2 5446
FishVal
2,653 Expert 2GB
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
8,834 Expert 8TB
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

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

Similar topics

8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
2
by: js | last post by:
I have a table rendered with XSLT. The first column has a radio button controls for user to make a selection for a particular row. All the values in the remaining columns are all concated with a...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
5
by: Nathan Sokalski | last post by:
My Web.config file contains the following section to register some of my UserControls: <pages> <controls> <add tagPrefix="NATE" tagName="Banner" src="~/Banner.ascx"/> <add tagPrefix="NATE"...
14
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.