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.txtMainFormField
set dbs = access.currentdb
set rst = rst.openrecordset(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 3 2093
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****@antarctic.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.txtMainFormField
set dbs = access.currentdb set rst = rst.openrecordset(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
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
Tim Marshall wrote:
As well as Steve's suggestions... set rst = rst.openrecordset(strsql, dbopensnapshot)
Apart from the obvious typo :-) Consider:
set rst = dbs.openrecordset(strsql, dbopenDynaset,dbReadOnly)
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,Len(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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?
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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 &...
|
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),...
|
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,...
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
| |