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!

Call functions in a diff form

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
How do I refer to one form from another? I have a main form. User is in a different form (not a subform) and I need to call some functions from my main form and set some controls on my main form. I have tried all different things and none are working. This must be a simle thing to do!
Any suggestions would be greatly appreciated.
Thanks
 
if you create a public function it should be available from anywhere.

Can you explain what exactly you are trying to do. You can refer to controls on other forms by using -

Form_yourformnamehere.yourcontrolnamehere

 
I have to do several things. The one I am having the most difficulty with is the following:
I have a recordset on my second form. I need to set my main form (a bound form)to the recordset on the second form. I tried this which does not work:
Set Forms!Company.Recordset = rs
 
Sorry, i'm not sure of that. what's your error message? can I ask why do you need two forms to show the same rs?
 
I don't. The second form is a reminder to the user. If the user selects open item then I want that to load on the main form.
 
From form itself
Me.ControlName

From another form
Forms!FormName.ControlName

Or if you want to control the second form then Use "OpenArgs" to the second form



Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
I tried that:

Set Forms!Company.Recordset = rs

I get the following error:
'Microsoft Access can't find the form 'Company' referred to in a macro expression or Visual Basic Code.'
 
Can you post your code in detail? and also some more information

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
I have an application which is the front end to a database with 30,000 clients. When user selects a client, the whole form loads to that record. The user can then type in 'actions' such as calls, meetings, etc. with that client. I have a reminder form. The user can set it to go off any time. When it is time for the reminder a screen pops up with all the data about the reminder. (All this works fine). It will remind him to call or email a certain client. The name of the client is on the reminder form with a note. I'd like the user to be able to click on a button called 'Open Item' and the reminder screen will close (that part I can do) and then the main screen will load with that company. So I have the company id on reminder form but not on the main form. So I want to load the main form from the reminder form.

Dim rs As New ADODB.Recordset
rs.Open "select * from company where company_id=" & Me!txtCompID.Value, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set Forms!Company.Recordset = rs
 
Few things
[ul]
[li] Dim rs As ADODB.Recordset not Dim rs As New ADODB.Recordset[/li]
[li] You must have a company id on the main form to pass parameter[/li]
[li] Bind the recordset first then close the reminder form [/li]
[li]change Set Forms!Company.Recordset = rs to Forms!Company.RecordSource = rs [/li]
[/ul]

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Thanks,
I just tried that and I got the following error:
Invalid use of property, with Recordsource highlighted.
 
Sorry I can't get it work now. I will post if I can find the solution. I have to create a similar db to test

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top