473,385 Members | 1,742 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,385 software developers and data experts.

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, qdfMarkedAddnlOwnerRecs As QueryDef,
rstMarkedAddnlOwners As Recordset
110 Dim PString2 As String, PLong As Long
120 Set MyDB = CurrentDb ' Set MyDB =
OpenDatabase("Northwind.mdb") is alternate syntax.
130 WaitTime = DLookup("[CertMailResponseWaitTime]", "tblAdmin")
140 With MyDB
149 Set qdfMarkedAddnlOwnerRecs = .CreateQueryDef("", "Select *
From tblAddnlOwners Where [AOActionMark]=True;")
150 Set rstMarkedAddnlOwners =
..OpenRecordset("qdfMarkedAddnlOwnerRecs", dbOpenSnapshot)
230 With rstMarkedAddnlOwners
240 .MoveFirst
250 Do Until rstMarkedAddnlOwners.EOF
260 PLong = !VehicleJobID
270 If IsNull(PLong) Then
280 .Edit
290 !VehicleJobID = CurrentVehicleJobID
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]",
"qryVehiclesNowners", "[VehicleJobID]=GetCurrentVehicleJobID()")
350 PString2 =
Trim$(CStr(DLookup("[VehicleJobTDstamp]", "tblVehicleJobs",
"[VehicleJobID]=GetCurrentVehicleJobID()")))
360 PString = PString & " entered on " & PString2
& ". Did you intend to make " & !AddnlOwnrFName & " " &
!AddnlOwnrLName
370 PString2 = Trim$(CStr(DLookup("[VDescr]",
"qryVehiclesNowners", "[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(PString, "Well, did you?",
vbQuestion, vbDefaultButton1)
' IF NO, DO NOTHING. IF ANSWER=YES, THEN APPEND
AN ADDITIONAL RECORD FOR BEN FIX TO tblAddnlOwnrs, SET ITS
[VehicleJobID] FIELD=CURRENTVEHICLEJOBID.
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 "frmBigMsgBox", , , , ,
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
' !AddnlOwnrCounty
' !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 1185
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**@NorthState.net> wrote in message
news:ht********************************@4ax.com...
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, qdfMarkedAddnlOwnerRecs As QueryDef,
rstMarkedAddnlOwners As Recordset
110 Dim PString2 As String, PLong As Long
120 Set MyDB = CurrentDb ' Set MyDB =
OpenDatabase("Northwind.mdb") is alternate syntax.
130 WaitTime = DLookup("[CertMailResponseWaitTime]", "tblAdmin")
140 With MyDB
149 Set qdfMarkedAddnlOwnerRecs = .CreateQueryDef("", "Select *
From tblAddnlOwners Where [AOActionMark]=True;")
150 Set rstMarkedAddnlOwners =
.OpenRecordset("qdfMarkedAddnlOwnerRecs", dbOpenSnapshot)
230 With rstMarkedAddnlOwners
240 .MoveFirst
250 Do Until rstMarkedAddnlOwners.EOF
260 PLong = !VehicleJobID
270 If IsNull(PLong) Then
280 .Edit
290 !VehicleJobID = CurrentVehicleJobID
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]",
"qryVehiclesNowners", "[VehicleJobID]=GetCurrentVehicleJobID()")
350 PString2 =
Trim$(CStr(DLookup("[VehicleJobTDstamp]", "tblVehicleJobs",
"[VehicleJobID]=GetCurrentVehicleJobID()")))
360 PString = PString & " entered on " & PString2
& ". Did you intend to make " & !AddnlOwnrFName & " " &
!AddnlOwnrLName
370 PString2 = Trim$(CStr(DLookup("[VDescr]",
"qryVehiclesNowners", "[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(PString, "Well, did you?",
vbQuestion, vbDefaultButton1)
' IF NO, DO NOTHING. IF ANSWER=YES, THEN APPEND
AN ADDITIONAL RECORD FOR BEN FIX TO tblAddnlOwnrs, SET ITS
[VehicleJobID] FIELD=CURRENTVEHICLEJOBID.
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 "frmBigMsgBox", , , , ,
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
' !AddnlOwnrCounty
' !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
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...
3
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...
5
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...
13
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...
3
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...
11
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: ...
23
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...
29
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...
29
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...
4
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...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: 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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.