-
Oct 1st, 2007, 05:47 AM
#1
Thread Starter
Lively Member
if.. to query as rowsource
hello guys.
i m using MSaccess to build a database.
the acess consists of a main form and a subform.
i need to specify the rowsource(a query) of a field in the subfrom based on the value of a field on a main form in VB code.
the thing is that i m not able to reference to the query to make it a rowsource in VB code.
can anybody help and thx
like
if form_mainform.field.value="xxx" then form_subform.field1.rowsource=??(query reference).
-
Oct 2nd, 2007, 03:00 AM
#2
Re: if.. to query as rowsource
Well an easy and quick solution, since it looks like you're searching for a particular record with this, is to go to the query you are using as your subform and open it in design mode.
Then, find the field in your query that corresponds to the field on your form, like "FullName". Under criteria, type [Tempvars]![FullName].
Then write a quick macro to CreateTempVar, make sure that the name of your tempvar is "FullName" and the source is [yourform]![yourfield].
In your form, use the AfterUpdate event for your field and use this
Code:
DoCmd.RunMacro "YourMacro"
form_subform.Requery
-
Oct 2nd, 2007, 03:36 AM
#3
New Member
Re: if.. to query as rowsource
hiii
i am using VB 6.0. It does not show 'database' as a keyword, it gives
Compiler Error: User-defined type not defined.
In all d example codes, 'database' is assumed to be a keyword.
Is the problem with the installation of VB? The VB that I have installed does not have MSDN collection. Should I try reinstalling VB??
-
Oct 2nd, 2007, 07:39 AM
#4
Re: if.. to query as rowsource
Smitas,
you need to add a reference of your required database object to your project.
What database you are using and what is the technology you want to use...
If DAO then select Microsoft DAO 3.51 Object Library from Project Menu -> References submenu.
Or if you want to use ADO then select Microsoft Activex Data Objects x.x Library
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Oct 2nd, 2007, 10:28 AM
#5
Re: if.. to query as rowsource
is that really necessary though? If you are using DAO then what about the expression
Code:
Set database = CurrentDb()
-
Oct 2nd, 2007, 10:33 AM
#6
Re: if.. to query as rowsource
At this point if you ate using VB6 to write the app I would not l=even think of using DAO use ADO. DAO was out of date in about 1997
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 2nd, 2007, 11:42 AM
#7
New Member
Re: if.. to query as rowsource
Originally Posted by ganeshmoorthy
Smitas,
you need to add a reference of your required database object to your project.
What database you are using and what is the technology you want to use...
If DAO then select Microsoft DAO 3.51 Object Library from Project Menu -> References submenu.
Or if you want to use ADO then select Microsoft Activex Data Objects x.x Library
Thanks a lot for the info.
I have never worked with VB database connections before.
I have 2 make a management system for a local trust. Is using MS Access fine, or is there a better way to connect to ?
Can u tell me wat is DSN & how it is related ?
Set db = ws.OpenDatabase("", False, False, strConnection)
What does this line do?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|