473,943 Members | 20,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DAO rst Methods in OnCurrent Event - Unwise?

In A2003, I have a bound continuous form (OK, actually a sub form of an
unbound main form, but I don't think that matters here). The record
source consists of an Jet SQL statement that returns one record per the
entity that I want to display on the form. There is another table, not
included with the form's SQL source that has a one to many relationship
with the table in the form's SQL statement that gives additional
information about one or more (or no) records each one of the records in
the form may be linked to.

What I'd like to have is a text box or two in the footer of the form
that shows this additional information. My intent would be to use the
on current event of the form to populate the text box, something like
the air code that follows.

But wouldn't this be a large drain on resources? Or is it an acceptable
technique?

dim StrSql as string
dim rst as dao.recordset
dim dbs as dao.database
dim strData as string

strSql = "Select Stuff from OtherTable where Pointer = " &
me.txtMainFormF ield

set dbs = access.currentd b
set rst = rst.openrecords et(strsql, dbopensnapshot)

strData = ""

with rst

if .eof then
goto exit_proc
else
.movefirst

do while .eof = false

if strData <> "" then strData = strData & vbcrlf

strData = strData & .fields!Stuff

.movenext

loop

.close

end if

Exit_Proc:

'close stuff and end
--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #1
3 2109
The resource drain should not be too bad. You could make it a little faster
by keeping the dbs variable at the form module level, and also using a
parameterized query in a temporary querydef, also held at the form level.

On Sun, 14 Nov 2004 10:56:52 -0330, Tim Marshall <TI****@antarct ic.flowerpots>
wrote:
In A2003, I have a bound continuous form (OK, actually a sub form of an
unbound main form, but I don't think that matters here). The record
source consists of an Jet SQL statement that returns one record per the
entity that I want to display on the form. There is another table, not
included with the form's SQL source that has a one to many relationship
with the table in the form's SQL statement that gives additional
information about one or more (or no) records each one of the records in
the form may be linked to.

What I'd like to have is a text box or two in the footer of the form
that shows this additional information. My intent would be to use the
on current event of the form to populate the text box, something like
the air code that follows.

But wouldn't this be a large drain on resources? Or is it an acceptable
technique?

dim StrSql as string
dim rst as dao.recordset
dim dbs as dao.database
dim strData as string

strSql = "Select Stuff from OtherTable where Pointer = " &
me.txtMainForm Field

set dbs = access.currentd b
set rst = rst.openrecords et(strsql, dbopensnapshot)

strData = ""

with rst

if .eof then
goto exit_proc
else
.movefirst

do while .eof = false

if strData <> "" then strData = strData & vbcrlf

strData = strData & .fields!Stuff

.movenext

loop

.close

end if

Exit_Proc:

'close stuff and end


Nov 13 '05 #2
Steve Jorgensen wrote:
The resource drain should not be too bad. You could make it a little faster
by keeping the dbs variable at the form module level, and also using a
parameterized query in a temporary querydef, also held at the form level.


Thank you Steve. I regularly wonder about these things - due to the
huge amount of reporting and manipulation of data I do, I demanded a PC
with 2 gigs of ram. I have to remember the most anyone in our
department has beside me is 512 and most, less than that.

--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #3
Tim Marshall wrote:

As well as Steve's suggestions...
set rst = rst.openrecords et(strsql, dbopensnapshot)
Apart from the obvious typo :-) Consider:
set rst = dbs.openrecords et(strsql, dbopenDynaset,d bReadOnly)
if strData <> "" then strData = strData & vbcrlf


Consider:
If Len(strData) Then

But then I see what you're doing in that loop, you may also consider
just adding the VbCrLf in any case and stripping it off at the end, e.g.

Do...
strData = strData & .fields!Stuff & vbCrLf
...
Loop
strData = Left$(strData,L en(strData)-2)

I realise the second lot is all string stuff and millisecond stuff, but
then I don't know how long your loop will last.

--
This sig left intentionally blank
Nov 13 '05 #4

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

Similar topics

4
3675
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the events in the <img> tag). <input id="StdDev Value" name="StdDevButton" type="button" value="Standard Deviation Value" onclick="readStdDevValue()"/>
7
2586
by: Weaver | last post by:
I need to check the status of some records (detail records in a master detail form) _before_ moving off the current master record. Anyone know what event will catch this?
2
1543
by: Mark | last post by:
I have added some VBA code to a form's OnCurrent event, intending to retrieve information about the record that I am scrolling _to_. Instead, this code is retrieving information about the record that I am scrolling _away_ from. As you might expect, the control to which I am writing this information is not staying in sync with the other information on the form. Suggestions?
8
2050
by: Michael McDowell | last post by:
I'm confused: "why do we need to assign a method to a delegate then assign the delegate to an event why not just assign the method to the events event handler" and "how does making a callback to some method differ from calling the method as per normal"?
12
5573
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
2
3445
by: Rational Repairs | last post by:
I have run into a sudden problem and thought I'd see if anyone else has ran into this. Out of nowhere (sort-of) I am not able to access the OnCurrent event on a subform. I, of course, can write code for the event, but under OnCurrent does not show up on the properties of the subform, and the event does not fire. When this problem happened, it seems to have also generated an error while changing records in the Main Form. The error is...
5
7535
by: TomK | last post by:
I would like to use the oncurrent event of a subform. The subform class seems to offer onEnter and onExit only, so I tried up to set the event handling routine programatically. It works fine with a macro: MySubForm.Form.OnCurrent = "MyMacro" But what about using VBA code? What procedure name does Access expect after having found MySubForm.Form.OnCurrent = "" ? MySubForm.Form.Name is "myQuery" so I tried up to define
1
1382
by: Maciej Franciszkowski | last post by:
Hello, I dont know why only else part of if statement is effected when using below Private Sub Form_Current() If Me.NewRecord Then Me!nrpoz = DMax("", "", "= '" & Me.Parent.Nr_artykulu & "'") + 1 Else
6
1927
by: Curious | last post by:
I have an arraylist used in three separate methods. In method #1 (event method), some items are removed from the arraylist if certain conditions are met; In method #2 (event method), properties of some items are modified if certain conditions are met; In method #3, it loops through each item in the arraylist without changing any item on the arraylist or removing any item from the
0
9970
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11299
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6308
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.