Invalid Use of Property!?!? ><

kwokv616

Registered User.
Local time
Today, 03:53
Joined
Nov 10, 2008
Messages
46
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!!
 
Seems you have a control and sub routine with the same name CSV

A more structured code would appear as follows

Code:
Private Sub CmdCSV_Click()
 Call CSV(Me.VDate)
End Sub


Code:
Private Sub SubCSV(valDate As Date)

Dim rst_p As DAO.Recordset
Dim rst_r As DAO.Recordset

Set rst_p = CurrentDb.OpenRecordset("Select * From Pol Order By [PrimaryKey]")
Set rst_r = CurrentDb.OpenRecordset("Select * From Rid Order By [PrimaryKey]")

etc...


Me.VDate is the form control that contains the date
Me.CmdCSV is thge name of the command button that calls the sub
SubCSV is the subroutine that is called from the command button


David
 

Users who are viewing this thread

Back
Top Bottom