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!

How can I use the value of the current record in a query? 2

Status
Not open for further replies.

Mabjro

Programmer
Jun 3, 2003
127
US
I have created an instance of a form using the following procedure;

Public Sub OpenFormSelectReportByTitle()
Dim frm1 As Form
Set frm1 = Form_frmSelectReport
frm1.RecordSource = "qryFindReportByTitle"
MsgBox frm1.RecordSource
frm1.Visible = True

End Sub

How can I use the current value of a field on frm1 as search criteria in a QBF? (query by form)
The following does not work.
form!frmSelectReport!txt1 or
form!frm1!txt1

Thank you,
Mabjro
 
Hello,

HI Mabjro

I've tried to follow this thread, but you know how it is when brain fade sets in. :eek:) (and I know how you feel about getting talked down to)

Anyway, I use instantiations of search forms frequently. To make the forms useable I declare a global :

public gSearchForm as Form

in a module I designate for public constants etc..

I subsequently set and reset this in VB. It works well.

I hope you can use it.

JohnH
 
Thank you JHowley58 for your input. I am not sure I understand your suggestion due to my own deficiencies. I think you are suggesting that I create a public variable = to the index number of the form instance and reuse the variable as needed. If I am misunderstanding, please tell me. Also, thanks for your comments about being talked down to, but I think I may have over reacted a little bit and vbajock has put forth a major effort to help me on this thread. Perhaps it was my ego that was hurt a little in the beginning. Anyway, I have a lot to toy with. I will check back today and hopefully have good news about my "frm1".

Thank you,
Mabjro
 
So close. I now know that the index number of the form is 7. (for now). I am not sure how to use this number to grab hold of the form for the query. In other words, how can I use the index value of the member of the form class in a query? I wish I could show you what I have tried, but I'm not sure where to go from here.

Thanks,
Mabrjo
 
You can't. You have to assign the value to a global using a function, and use the function in the query.
 
Let's say the index number is 3 and let's forget about the query for a minute. To create this public variable, can I do something like;

Public Function Test()

Dim publicFrm1 as (form, string, ?)

publicFrm1 = Allforms.Item(i)


I'm trying to figure out what I can do with the 3. In theory, I understand what you (vbaJock) are telling me. Am I on the right track at all? I may take this to allexperts.com soon as I think I have just about overstayed my welcome with this problem. If you can clarify this final question that would be great and thanks for all your help. If you think I need to explore other options, I totaly understand, just let me know.

Thanks again,
Mabjro

 
Use some event on your form to assign the value to a global. For example, you have a text box on your instatiated form, that has a default value of 0. In the load event of the form you assign the value of 0 to a global variable. If the user changes the value to 2, you put a call to change the value to 2 in the text box exit or change event.


 
vbaJock, I am going to have to chew on that for a while. I will get back later.
 
I'm not going to continue this thread. Thank you everyone for your help. I need to do more homework and tomorrow I am getting another book. I will check back, just incase anyone has any recommendations on a book. I am very close to solving this problem. It has become a personal challenge. Some time in the not to far future (I hope) I will be able to post back and intelligently explain the issues and solutions associated with this thread.

Thanks one last time.

Sincerely,

Mabjro

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top