473,385 Members | 2,028 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.

Calling query which uses alias results in different value Version

Hello, and thank you for your help. I have a query that I call from a
VBA function which results in a different value than when viewed in the
datasheet window. The query does a calculation, and stores an
intermediate value using an alias, then uses that value to
format(round()) so that a pdf file can accept it. If I don't use the
intermediate alias (I use it as this value is also used for other
calculations) it works fine. Also, when I view the value either in
datasheet view, or from within a form - it's correct. But after coming
out of the function - it is incorrect.

The code is below.

Function MergeAndPrint4(tableName As String, pdfPath As String,
prntrName As String)

Dim ofArray As Variant
Dim base As String
Dim xfdfFileName As String
Dim Rec As Integer
Dim hFile As Long
Dim Vacuum_Gyro_ID As Long

Dim rst As New ADODB.Recordset
Set objShell = CreateObject("WScript.Shell")

If Dir(pdfPath) = "" Then
pdfPath = CurrentProject.Path & "\" & pdfPath
If Dir(pdfPath) = "" Then
MsgBox "ERROR - File Not Found: '" & pdfPath & "'"
Exit Function
End If
End If

' get the Vacuum_Gyro_ID from the frm1903B_VacuumGyro
Vacuum_Gyro_ID = [Forms]![frm1903B_VacuumGyro]![Vaccum_Gyro_ID]

DoCmd.Close

ofArray = Split(pdfPath, ".", 2)
base = ofArray(0)
Debug.Print base

SQL = Trim(SQLGet_MEI("1903B_VacuumGyroqry"))
SQL = Left(SQL, Len(SQL) - 3) & " WHERE
(tblJMF_VacuumGyro.Vacuum_Gyro_ID=" & Vacuum_Gyro_ID & ");"
Debug.Print SQL

rst.Open SQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rst.MoveFirst
firstJob = True

MsgBox "rst!con19 is " & rst!con19 & ""
Rec = 1

rst.Close
End Function

Thank you again for your help.
Lex

Mar 1 '06 #1
1 1474
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What's the SQL statement look like? Is there a column named "con19"?

If you know the column position you can use rst(x), where x is the
column position-1. E.g.:

SELECT colA, colB, colC ...

rst(2) would return the value of colC. The rst() index is zero-based.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAYESoechKqOuFEgEQJaxACfbb/6cA3ko8K3Lxh+qQK7ilV9NZIAoKan
rot570zUljmUfT81Zi8zJzuz
=LNrJ
-----END PGP SIGNATURE-----
ak*****@umich.edu wrote:
Hello, and thank you for your help. I have a query that I call from a
VBA function which results in a different value than when viewed in the
datasheet window. The query does a calculation, and stores an
intermediate value using an alias, then uses that value to
format(round()) so that a pdf file can accept it. If I don't use the
intermediate alias (I use it as this value is also used for other
calculations) it works fine. Also, when I view the value either in
datasheet view, or from within a form - it's correct. But after coming
out of the function - it is incorrect.

The code is below.

Function MergeAndPrint4(tableName As String, pdfPath As String,
prntrName As String)

Dim ofArray As Variant
Dim base As String
Dim xfdfFileName As String
Dim Rec As Integer
Dim hFile As Long
Dim Vacuum_Gyro_ID As Long

Dim rst As New ADODB.Recordset
Set objShell = CreateObject("WScript.Shell")

If Dir(pdfPath) = "" Then
pdfPath = CurrentProject.Path & "\" & pdfPath
If Dir(pdfPath) = "" Then
MsgBox "ERROR - File Not Found: '" & pdfPath & "'"
Exit Function
End If
End If

' get the Vacuum_Gyro_ID from the frm1903B_VacuumGyro
Vacuum_Gyro_ID = [Forms]![frm1903B_VacuumGyro]![Vaccum_Gyro_ID]

DoCmd.Close

ofArray = Split(pdfPath, ".", 2)
base = ofArray(0)
Debug.Print base

SQL = Trim(SQLGet_MEI("1903B_VacuumGyroqry"))
SQL = Left(SQL, Len(SQL) - 3) & " WHERE
(tblJMF_VacuumGyro.Vacuum_Gyro_ID=" & Vacuum_Gyro_ID & ");"
Debug.Print SQL

rst.Open SQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
rst.MoveFirst
firstJob = True

MsgBox "rst!con19 is " & rst!con19 & ""
Rec = 1

rst.Close
End Function

Mar 1 '06 #2

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

Similar topics

1
by: Martin | last post by:
Hi I'm having trouble with the script below that it just won't do a correct ORDER BY for a date field. When executing the two SELECT TOP statements on their own the records are sorted...
2
by: muzamil | last post by:
Hi Your help for the following query will be highly apprecaited. I've wasted alot of time on it. Data definition is at the bottom. Thanks -----------------------------------
4
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
2
by: Lyn | last post by:
Hi, How do you bind the output columns from a UNION query when the fields from the two tables have different names? Consider this query (WHERE clauses omitted)... SELECT SurnameBirth,...
2
by: Alex Scollay | last post by:
Let's say I have a column whose values are all 2-digit integers, e.g. 82 (though it's actually a varchar field). From now on, the column will be able to have 2-digit as well as 3-digit integers....
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
0
by: akinter | last post by:
Hello, and thank you for your help. I have a query that I call from a VBA function which results in a different value than when viewed in the datasheet window. The query does a calculation, and...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
5
by: redstamp | last post by:
Try as I might I cannot find a way to write an access query to return a result set with the records from my database WITHOUT a certain set of values within a field. To explain, I have a table of...
0
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,...
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?
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...
0
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,...
0
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...

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.