473,808 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unsure where my pointer goes in DAO?

MLH
Say I'm walking a subset of the records in tblAddnlOwners
via DAO. Suppose there are 5 records in the extract and that
I MoveFirst, MoveNext and MoveNext. Then,
when on the 3rd of 5 records, I determine the
need to append a record to tblAddnlOwners.
So, I use AddNew and do it.

Now, I'd like to keep on walking the records.
I wanna go to the 4th then the 5th and be done
with it all. As I'm walking, I might have to append
a new record to tblAddnlOwners at any (or all) of
the 5-steps along the way. I don't want things to
get out of order in the process. I've read the HELP.
I still think I need a little hand-holding here.

Here's part of the code I use ...
100 Dim MyDB As Database, qdfMarkedAddnlO wnerRecs As QueryDef,
rstMarkedAddnlO wners As Recordset
110 Dim PString2 As String, PLong As Long
120 Set MyDB = CurrentDb ' Set MyDB =
OpenDatabase("N orthwind.mdb") is alternate syntax.
130 WaitTime = DLookup("[CertMailRespons eWaitTime]", "tblAdmin")
140 With MyDB
149 Set qdfMarkedAddnlO wnerRecs = .CreateQueryDef ("", "Select *
From tblAddnlOwners Where [AOActionMark]=True;")
150 Set rstMarkedAddnlO wners =
..OpenRecordset ("qdfMarkedAddn lOwnerRecs", dbOpenSnapshot)
230 With rstMarkedAddnlO wners
240 .MoveFirst
250 Do Until rstMarkedAddnlO wners.EOF
260 PLong = !VehicleJobID
270 If IsNull(PLong) Then
280 .Edit
290 !VehicleJobID = CurrentVehicleJ obID
300 .Update
310 Else
320 OtherColor = PLong
' SAY "BEN FIX IS ALREADY LISTED AS BEING THE
OWNER OF A 1979 CORVETTE ENTERED ON JULY 22, 1996.
' DID YOU INTEND TO MAKE BEN FIX AN ADDITIONAL
OWNER OF THE 2006 CHRYSLER YOU JUST ENTERED AS WELL?
330 PString = !AddnlOwnrFName & " " &
!AddnlOwnrLName & " is already listed as beingthe owner of a "
340 PString = PString & DLookup("[VDescr]",
"qryVehiclesNow ners", "[VehicleJobID]=GetCurrentVehi cleJobID()")
350 PString2 =
Trim$(CStr(DLoo kup("[VehicleJobTDsta mp]", "tblVehicleJobs ",
"[VehicleJobID]=GetCurrentVehi cleJobID()")))
360 PString = PString & " entered on " & PString2
& ". Did you intend to make " & !AddnlOwnrFName & " " &
!AddnlOwnrLName
370 PString2 = Trim$(CStr(DLoo kup("[VDescr]",
"qryVehiclesNow ners", "[VehicleJobID]=GetOtherColor( )")))
380 PString = PString & " an additional owner of
the " & PString2 & " you just entered as well?"
390 PString = PString & ""
400 PString = PString & ""
410 Response = AskUserQ(PStrin g, "Well, did you?",
vbQuestion, vbDefaultButton 1)
' IF NO, DO NOTHING. IF ANSWER=YES, THEN APPEND
AN ADDITIONAL RECORD FOR BEN FIX TO tblAddnlOwnrs, SET ITS
[VehicleJobID] FIELD=CURRENTVE HICLEJOBID.
420 If Response = False Then '
430 PString = "As you wish. No additional
owners will be recorded for this vehicle. FYI: To enter additional "
440 PString = PString & "owners later on for
any vehicle already on file in Tow-Pak, click Data Management "
450 PString = PString & "on the main menu and
Button-R on the Administrative Activity form."
460 DoCmd.OpenForm "frmBigMsgB ox", , , , ,
acDialog, PString
470 End If
' GATHER THE DATA AND APPEND A RECORD TO
TBLADDNLOWNERS USING SOMETHING LIKE THIS
' .AddNew
' !VehicleJobID
' !AddnlOwnrFName
' !AddnlOwnrLName
' !AddnlOwnrAddr
' !AddnlOwnrPObox
' !AddnlOwnrCity
' !AddnlOwnrState
' !AddnlOwnrZip
' !AddnlOwnrCount y
' !AddnlOwnrPhone
' !AddnlOwnrTaxID
' !UserID
' .Update
480 End If
490 Loop
500 .Close

What I want to be sure of is that I don't get stuff out
of order between lines 470 and 480. Sorry about the
length of these lines. You'll probably have to cut 'n
paste it into a wider frame to make sense of it.
Mar 24 '06 #1
2 1200
Without going through your code, just a quick comment that may help.

Open 2 recordsets, the 5 records you mention as a snapshot and the full
table as a dynaset. You would then go through the 5 records in the snapshot.
Since the snapshot isn't editable, you don't have to worry about the new
records you add affecting it. If you need to add records, add them to the
dynaset recordset that you also opened. It won't matter where in the table
they get added. Your 5 records in the snapshot that you're stepping through
will still be there, untouched. When you're ready to go to the next record
in the snapshot, just MoveNext (until EOF, of course).

--
Wayne Morgan
MS Access MVP
"MLH" <CR**@NorthStat e.net> wrote in message
news:ht******** *************** *********@4ax.c om...
Say I'm walking a subset of the records in tblAddnlOwners
via DAO. Suppose there are 5 records in the extract and that
I MoveFirst, MoveNext and MoveNext. Then,
when on the 3rd of 5 records, I determine the
need to append a record to tblAddnlOwners.
So, I use AddNew and do it.

Now, I'd like to keep on walking the records.
I wanna go to the 4th then the 5th and be done
with it all. As I'm walking, I might have to append
a new record to tblAddnlOwners at any (or all) of
the 5-steps along the way. I don't want things to
get out of order in the process. I've read the HELP.
I still think I need a little hand-holding here.

Here's part of the code I use ...
100 Dim MyDB As Database, qdfMarkedAddnlO wnerRecs As QueryDef,
rstMarkedAddnlO wners As Recordset
110 Dim PString2 As String, PLong As Long
120 Set MyDB = CurrentDb ' Set MyDB =
OpenDatabase("N orthwind.mdb") is alternate syntax.
130 WaitTime = DLookup("[CertMailRespons eWaitTime]", "tblAdmin")
140 With MyDB
149 Set qdfMarkedAddnlO wnerRecs = .CreateQueryDef ("", "Select *
From tblAddnlOwners Where [AOActionMark]=True;")
150 Set rstMarkedAddnlO wners =
.OpenRecordset( "qdfMarkedAddnl OwnerRecs", dbOpenSnapshot)
230 With rstMarkedAddnlO wners
240 .MoveFirst
250 Do Until rstMarkedAddnlO wners.EOF
260 PLong = !VehicleJobID
270 If IsNull(PLong) Then
280 .Edit
290 !VehicleJobID = CurrentVehicleJ obID
300 .Update
310 Else
320 OtherColor = PLong
' SAY "BEN FIX IS ALREADY LISTED AS BEING THE
OWNER OF A 1979 CORVETTE ENTERED ON JULY 22, 1996.
' DID YOU INTEND TO MAKE BEN FIX AN ADDITIONAL
OWNER OF THE 2006 CHRYSLER YOU JUST ENTERED AS WELL?
330 PString = !AddnlOwnrFName & " " &
!AddnlOwnrLName & " is already listed as beingthe owner of a "
340 PString = PString & DLookup("[VDescr]",
"qryVehiclesNow ners", "[VehicleJobID]=GetCurrentVehi cleJobID()")
350 PString2 =
Trim$(CStr(DLoo kup("[VehicleJobTDsta mp]", "tblVehicleJobs ",
"[VehicleJobID]=GetCurrentVehi cleJobID()")))
360 PString = PString & " entered on " & PString2
& ". Did you intend to make " & !AddnlOwnrFName & " " &
!AddnlOwnrLName
370 PString2 = Trim$(CStr(DLoo kup("[VDescr]",
"qryVehiclesNow ners", "[VehicleJobID]=GetOtherColor( )")))
380 PString = PString & " an additional owner of
the " & PString2 & " you just entered as well?"
390 PString = PString & ""
400 PString = PString & ""
410 Response = AskUserQ(PStrin g, "Well, did you?",
vbQuestion, vbDefaultButton 1)
' IF NO, DO NOTHING. IF ANSWER=YES, THEN APPEND
AN ADDITIONAL RECORD FOR BEN FIX TO tblAddnlOwnrs, SET ITS
[VehicleJobID] FIELD=CURRENTVE HICLEJOBID.
420 If Response = False Then '
430 PString = "As you wish. No additional
owners will be recorded for this vehicle. FYI: To enter additional "
440 PString = PString & "owners later on for
any vehicle already on file in Tow-Pak, click Data Management "
450 PString = PString & "on the main menu and
Button-R on the Administrative Activity form."
460 DoCmd.OpenForm "frmBigMsgB ox", , , , ,
acDialog, PString
470 End If
' GATHER THE DATA AND APPEND A RECORD TO
TBLADDNLOWNERS USING SOMETHING LIKE THIS
' .AddNew
' !VehicleJobID
' !AddnlOwnrFName
' !AddnlOwnrLName
' !AddnlOwnrAddr
' !AddnlOwnrPObox
' !AddnlOwnrCity
' !AddnlOwnrState
' !AddnlOwnrZip
' !AddnlOwnrCount y
' !AddnlOwnrPhone
' !AddnlOwnrTaxID
' !UserID
' .Update
480 End If
490 Loop
500 .Close

What I want to be sure of is that I don't get stuff out
of order between lines 470 and 480. Sorry about the
length of these lines. You'll probably have to cut 'n
paste it into a wider frame to make sense of it.

Mar 24 '06 #2
MLH
Thanks a bunch, Wayne. I'm sure that your comments
will help. I'll have a go at it.
Mar 24 '06 #3

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

Similar topics

5
2037
by: lawrence | last post by:
I posted before, but have now narrowed my problem down to this method. At the start of the method, I test to make sure that I have a resource, a pointer to data returned from a database. This test is coming back true, so the next line runs, which attempts to get the next row from the dataset. This brings back nothing. On the queries I'm running right now, the first row will be fetched, but then no further rows. If I expect 20 rows back, I...
3
20525
by: JoTo | last post by:
Hi Group, sorry for my for you surely dumb question. But i'm not so familiar with this reference- and pointerstew in C++ yet. Let me explain my problem with a little Codesnippet. If i do the following: void CServerSock::OnAccept(void)
5
1642
by: Tommy Lang | last post by:
Hi! I am trying to write a function that goes through an array of objects(class Student) and checks if object name(student name)matches search string(char *). I want the function to return a pointer to the object, if a match is found. This is my code so far...(am I even close? :-)) //I want to return a ponter of type student
13
2505
by: xuatla | last post by:
I encountered "segmentation fault" and I checked my code, found the following problem: I want to reallocate memory for an array. I defined the following function: int reallocateMemory( double *array, int newsize ) { if (array) delete array;
3
1914
by: Vijai Kalyan | last post by:
I have been thinking about this and it may have already been thrashed out and hung out to dry as a topic of no more interest but here goes. I found when implementing a smart pointer that the typical implementation goes like: template<typename T> class SmartPointer { // other stuff
11
1949
by: Sushil | last post by:
Hi Gurus I've tried to come up with a small logical example of my problem. The problem is platform specific (MIPS) which I understand should not be discussed here. So here goes my example: Code is doing malloc of variable sizes. The last byte of malloc.ed memory is written a magic.
23
7823
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when called, can be a genuine no-op. Consider: typedef int(*polymorphic_func)(int param);
29
3660
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a string to a integer number. bool Convert(const string& str, int* pData); bool Convert(const string& str, int& data);
29
7889
by: marvinla | last post by:
Hello! I'm a beginner in C, and I'm having trouble with a pointer-to-pointer reallocation. This piece of code works well, but Valkyrie warns some parts (pointed below), and is breaking my real code. #include <stdio.h> #include <stdlib.h>
4
2195
by: deanndra | last post by:
First, I want to say thank you to Scott and the others who replied to my first post here. I had to put that database on hold for the moment when I was tasked with a new one. I am building another database from scratch. This one is for job announcements. I've built only 2 tables (I know this is a no-no, but it was demanded by those wanting this database so I've complied). The field name properties and data types in both tables are virtually...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
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
6880
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.