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

Dlookup from a Query

9
I am using Access 97 (No choice) and I trying to get the VBA to do this.

1. Open a query "X-Misses-1"
2. Pull the value from the field "total misses"
3. Use that value in a loop to run an append query that # of times.

Here is where I am, and I am stuck on

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     Dim Temp As Integer
  3.     Dim Count As Integer
  4.  
  5.     stDocName = "X-Misses-1"
  6.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  7.     Temp = DLookup("[total misses]")
  8.  
  9.     Count = 1
  10.     Do While Count <= Temp
  11.  
  12.  
  13.     stDocName = "X-Missesappend"
  14.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  15.  
  16.     Count = Count + 1
  17.     Loop
  18.  
  19. Exit_Command54_Click:
  20.     Exit Sub
  21.  
  22. Err_Command54_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command54_Click
  25.  
Nov 20 '08 #1
1 2270
MikeTheBike
639 Expert 512MB
I am using Access 97 (No choice) and I trying to get the VBA to do this.

1. Open a query "X-Misses-1"
2. Pull the value from the field "total misses"
3. Use that value in a loop to run an append query that # of times.

Here is where I am, and I am stuck on

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     Dim Temp As Integer
  3.     Dim Count As Integer
  4.  
  5.     stDocName = "X-Misses-1"
  6.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  7.     Temp = DLookup("[total misses]")
  8.  
  9.     Count = 1
  10.     Do While Count <= Temp
  11.  
  12.  
  13.     stDocName = "X-Missesappend"
  14.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  15.  
  16.     Count = Count + 1
  17.     Loop
  18.  
  19. Exit_Command54_Click:
  20.     Exit Sub
  21.  
  22. Err_Command54_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command54_Click
  25.  
Hi

Assuming 'X-Misses-1' is a stored query then have you tried this

Temp = DLookup("[total misses]","X-Misses-1") ??

Note: if the query 'X-Misses-1' has more that one record, then it will return the value of 'total misses' from the first record (i believe?), otherwise you need to use the optional third element 'WHERE' clause in DLookUp.


MTB
Nov 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
3
by: DFS | last post by:
FYI, Using DLookup("ResultsField","Pass-thru query") consumes 2 SEQUENCE numbers each time it's called. Anyone know why?
7
by: Tony Williams | last post by:
Does DLookup work in an expression in a query? I have this expression -(DLookUp("","tblmaintabs","= ")) Which works fine as a calculated control on a form but when I try to use it in a query as an...
8
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
2
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An...
1
by: MLH | last post by:
I have a query that looks up records in tblReturnReceipts and other related tables. One of the other tables is tblCorrespondence. The resulting dynaset consists of five records. Each has a unique ...
3
by: hrreece | last post by:
I am trying to use the Dlookup expression in a macro to pull the value from the "Price" field in the following query. The query works fine and the Dlookup function did as well until I added a new...
30
by: DH22 | last post by:
Access 03 I'm currently having an issue using Dlookup when trying to reference a query (criteria syntax) Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key...
3
by: Kunal Desale | last post by:
Hello, I am migrating access queries to SQL Server 2005 Queries. My Access Query Is: SELECT qtrade.intordreftrim AS Expr1, qtrade.extordreftrim AS Expr2, qtrade.intinvreftrim AS Expr3,...
4
beacon
by: beacon | last post by:
I have a report that is pulling data from a query. The query gets sent a parameter from a form. The information on the form is correct, but my summary section is incorrect. The reason the summary...
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: 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: 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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.