Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code running problem

Status
Not open for further replies.

TTF

IS-IT--Management
Jan 12, 2005
59
US
I am running code4
Ok, when I am running it as a Module - table gets populated.
When I run it on Form cmd Click event I am still getting that error.

Public Function cmd_Run_Click()
Dim sSQL As String
Dim dbR As DAO.Database

Set dbR = CurrentDb()
DoCmd.SetWarnings True

sSQL = "Insert into Data_table SELECT [tbl_500 - Data].[Pay Date] FROM [tbl_500 - Data];"
dbR.Execute sSQL
lst_Cutoff_Dates.RowSource = sSQL

End Function

that gives me an error

The expression on click you entered ... produces ... error
The expression may not result in the name of macro
There may have been an error evaluating the function...
__________________________________________________________
However as a Module it runs as a dream and populated table.
-------------------------------------------------------------

Do you see anything wrong with my code? Thanks
 
I think it should work if you change it as below
Code:
[purple][b]Public Function[/b][/purple] cmd_Run_Click()
Dim sSQL As String
Dim dbR As DAO.Database
Set dbR = CurrentDb()
DoCmd.SetWarnings True
sSQL = "Insert into Data_table SELECT [tbl_500 - Data].[Pay Date] FROM [tbl_500 - Data];"
dbR.Execute sSQL
lst_Cutoff_Dates.RowSource = sSQL
[purple][b]End Function[/b][/purple]
Code:
[purple][b]Private Sub[/b][/purple] cmd_Run_Click()
[green]'Code here[/green]
[purple][b]End Sub[/b][/purple]
Also you should have reference to DAO xxx library.
regards

Zameer Abdulla
Visit Me
 
ZmrAbdulla ,
I have references to DAO 3.51

With your code I am getting this:
__________________________________________________________
The expression on click you entered as the event property setting produced the following error: Event procedure declaration does not match description of event having the same name

The expression on click you entered ... produces ... error
The expression may not result in the name of macro
There may have been an error evaluating the function...
___________________________________________________________

I am ready to kill myself :(

Thanks
 
Are you sure you don't have

[tt]Private Sub cmd_Run_Click()

End Sub [/tt]
twice some where in the code window?

I have checked again and it works fine.

Zameer Abdulla
Visit Me
 
See, this is why I am going nuts! Is this possible that Access installation somehow screwed up? Everyone outside of this place can run my codes but me, here.
Thanks and it works now but twiking took half a day:-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top