Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem Calling Public Procedure

Newbie
 
Join Date: Jul 2007
Location: Huntsville, AL
Posts: 3
#1: Jul 17 '07
I'm an old PowerBuilder developer that is new to Access development, and I'm stumbling on getting the rownum function to work. I've added the "rownum" public function to an existing module within my application, and I've added a textbox called "rownum" to my form with the controlsource you suggested. When I run my form, I get "#Error" displayed in the rownum textbox in each row of the form. Any idea what I might be doing wrong?

Thanks,
Jeff

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#2: Jul 17 '07

re: Problem Calling Public Procedure


I'm splitting this question into a thread of its own. It refers back to the Row numbers and alternate colors to a Continuous Form - simple and almost works article.

MODERATOR.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#3: Jul 17 '07

re: Problem Calling Public Procedure


If you have defined a TextBox named [RowNum] as well as a Public Function named [RowNum], then Access will think you are trying to access the TextBox rather than the Public Function. Try a more conventional name (like [txtRowNum]) for your TextBox instead.
Newbie
 
Join Date: Jul 2007
Location: Huntsville, AL
Posts: 3
#4: Jul 17 '07

re: Problem Calling Public Procedure


Unfortunately, I had tried changing the name of the textbox before, and still got the "#Error" displayed when I ran the form. Another thing I did was to put a debug breakpoint in the public "rownum" function, and it never triggered. I had copied the function declaration right out of the posting and into a module, so I'm not sure what I could've done wrong there. As a test, I created a new form from scratch, added a textbox in the detail band with the "=rownum(Forms!myform)" as Control Source, and still got the error. Any other ideas?

Thanks!

Jeff
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#5: Jul 17 '07

re: Problem Calling Public Procedure


What's the name and type of the module that it's defined in?
For good measure, can you post the relevant parts of the code here (The function definition and any public variables / constants it uses).

... & this may seem a silly question, but is your open form called [MyForm]?
Newbie
 
Join Date: Jul 2007
Location: Huntsville, AL
Posts: 3
#6: Jul 17 '07

re: Problem Calling Public Procedure


Eureka! Your "silly" question tied directly to my silly mistake of leaving "myform" in the control source of the text box. Once I specified the form correctly, and the function works and I have row numbers. I guess I still have a ways to go before I can call myself an Access developer... Thanks so much for your help!

Jeff
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#7: Jul 18 '07

re: Problem Calling Public Procedure


No problem Jeff.
Experience is just seeing all the little mistakes so many times. It's certainly not uncommon.
I'm pleased you got it sorted anyway :)
Reply