473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Table name and RecordSource

I have a procedure that goes like this:

Private Sub Form_Current()
Dim strSQL1 As String
strSQL1 = "Select Price_Year_Name from Price_Year where Category_ID = 1
And By_Default <> 0"

' I know that the result of the above query is 'Price_2003'
' I want to use the result of this query in RECORDSource property.
' How do I accomplish this?

Me.RecordSource = "Price_2003"
' I wish I could just handcode "Price_2003" to my RecordSource but I
couldn't ....
' RecordSource will change according to the table, in fact it was
determined by By_Default field
' in the table.

Please help .....

Jul 17 '05 #1
1 7302

"Jenny Kurniawan" <jk********@maxxiscanada.com> wrote in message
news:Qe*****************@news20.bellglobal.com...
I have a procedure that goes like this:

Private Sub Form_Current()
Dim strSQL1 As String
strSQL1 = "Select Price_Year_Name from Price_Year where Category_ID = 1 And By_Default <> 0"

' I know that the result of the above query is 'Price_2003'
' I want to use the result of this query in RECORDSource property. ' How do I accomplish this?

Me.RecordSource = "Price_2003"
' I wish I could just handcode "Price_2003" to my RecordSource but I couldn't ....
' RecordSource will change according to the table, in fact it was
determined by By_Default field
' in the table.

Please help .....


I may not be understanding you completely, but this is what I would do to
change the "record set" assuming you have a data control "data1"

' I would save the current record set

Dim varBookmark As Variant
Dim RecSrcSave As String

Dim strSQL1 As String

'-------------------------------
' first save our position in db
'-------------------------------
varBookmark = Data1.Recordset.Bookmark
' save the record source
RecSrcSave = Data1.RecordSource

strSQL1 = "Select Price_Year_Name from Price_Year where Category_ID = 1 And
By_Default <> 0"

' If needed you can change the db file
' Data1.DatabaseName = gFName

Data1.RecordSource = strSQL1 'set the record source to this query
Data1.Refresh 'execute it
' populate it
' if zero then no matching record
If (Data1.Recordset.BOF = True And Data1.Recordset.EOF = True) Then
MsgBox ("No records meet the criteria.")
End If

' else total records matching your query
' will be in Data1.Recordset.RecordCount

' On the way out restore bookmark

' Now restore things
' restore the record source
Data1.RecordSource = RecSrcSave
Data1.Refresh
' populate it
Data1.Recordset.MoveLast
Data1.Recordset.MoveFirst 'ensure populated
Data1.Recordset.Bookmark = varBookmark

Again, not sure if that's what you looking for. By the way, I knew a girl a
long time ago in Indonesia with the same name. E-mail me if you're from
there :)
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Annette Massie | last post by:
I have a database with a linked table within it. I have a query form that opens and allows the user to select criteria and then the form is filled with data found from the linked table. At...
2
by: deko | last post by:
This may be an easy question, but for some reason the multiple table design idea is throwing me. I'm trying to avoid using one large, wide table - so I've got multiple tables that hold different...
6
by: cyoung311 | last post by:
I'm trying to do an automatic update of one table from another through a form. Basically, when a selection is made for an item, in this case a particular workshop, I want to get the associated...
3
by: John Baker | last post by:
Hi: At the outset let me admit that I screwed up! I have built a rather elaborate set of forms and sub forms starting with a client table, and going down to PO and Line item. This works very...
6
by: thomas.jacobs | last post by:
I have reports formated and now need to use that format on another table name with the same field names as formated in the report. I belive it is in the properties but I can't seem to find it....
1
by: Beowulf | last post by:
I have a report laid out in Design View as shown at the end of this message. I have code that performs the following steps: 1. In main report's Report_Open(), DELETE any old rows in tblTOC for...
5
by: ladybug via AccessMonster.com | last post by:
I am trying to create a report using multiple tables. The first table has Employee info in it (name and id's). the next three tables have employee info for training, test, scores, etc. I am...
5
by: agarwasa2008 | last post by:
Hi, I have a linked table called tbltest and some bounded forms (which add, update, delete records) that were created using that linked table. For some necessary reasons I had to create another...
7
by: franc sutherland | last post by:
Hi everyone, I am using Access 2003. I have a database with a table in it which is linked to an excel spreadsheet. When I install the database on someone else's system, the pathname to the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.