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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling function on a form

Status
Not open for further replies.

hdesbiens

Programmer
May 2, 2004
77
CA
Hi

i have a form invoice that contains a subform invoice details, i have a function that detect when a key is pressed for differents actions on the form such as save, modify, next record, etc....

but when im on my subform to enter data for the invoice the keys are not detected, so i have tried to change my function that detect keys and make it public rather than private but it does not work.

i wonder how to call my function that is located in my principal form?

thanks a lot
 
The easiest would be to put the function in a standard module (not the forms module), and yes it needs to be public. I usually build a module called "mdlUtiilities" and put public variables, procedures, and functions that get used throughout the program.
 
ok perfect i have never used modules!!

so i put it there public and in my forms i juste have to call the func tion and thats it?

thanks a lot
 
Now that I reread that you may need a little more since it looks like you are trapping keypress events on both the main and the subform. So lets say you make a public function in a module you probably need events in both the main and the sub

so on both the main and the sub you have something like

private sub Form_keyPress(keyascii as integer)
call saveRecord(me.formName)
end sub

now in the module you could have a save record sub routine

public sub saveRecord(strFormName as string)
code that saves a record using the form name to tell which
form to save
end sub

But now that I reread your post, the form events of subform are not trapped by the main form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top