473,327 Members | 2,118 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,327 software developers and data experts.

Determine lastRecord keynumber

TTD
Hi,

When I open a form I want to determine which record is the last in the
tblCases. I've created a query where I copied the SQL code.
But when I want to give the output to MyVar, the content is "Dim strGetSQL
As String strGetSQL = "SELECT Max(tblCases.Casenummer) AS MaxVanCasenummer "
& "FROM tblCases " & "ORDER BY Max(tblCases.Casenummer);"

But I want the value of the keyrecord which name is Casenummer

This is my code

Dim strGetSQL As String
strGetSQL = "SELECT Max(tblCases.Casenummer) AS MaxVanCasenummer " _
& "FROM tblCases " _
& "ORDER BY Max(tblCases.Casenummer);"
MyVar = strGetSQL
What am I doing wrong?

Thanks in advance.
Nov 12 '05 #1
2 1163
"TTD" <tt*@hotmail.com> wrote in message
news:c7***********@beast.euro.net...
Hi,

When I open a form I want to determine which record is the last in the
tblCases. I've created a query where I copied the SQL code.
But when I want to give the output to MyVar, the content is "Dim strGetSQL As String strGetSQL = "SELECT Max(tblCases.Casenummer) AS MaxVanCasenummer " & "FROM tblCases " & "ORDER BY Max(tblCases.Casenummer);"

But I want the value of the keyrecord which name is Casenummer

This is my code

Dim strGetSQL As String
strGetSQL = "SELECT Max(tblCases.Casenummer) AS MaxVanCasenummer " _
& "FROM tblCases " _
& "ORDER BY Max(tblCases.Casenummer);"
MyVar = strGetSQL
What am I doing wrong?


Your trying to use a SQL string as if it were a function. Since it is
between quotes it is a string in your code, nothing more. To actually
*use* SQL in code you have to create a RecordSet based on the SQL and then
pull the values you want from the RecordSet. A simplified method of doing
that is using a Domain Aggregate function which can get the value for you.

MyVar = DMax("Casenummer", "tblCases")

BTW your SQL statement is only going to retrieve a single value so the
ORDER BY is superfluous.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 12 '05 #2
TTD

Thanks Rick,

you made it more clear to this newbie.

Appreciate it.
"Rick Brandt" <ri*********@hotmail.com> schreef in bericht
news:2g************@uni-berlin.de...
"TTD" <tt*@hotmail.com> wrote in message
news:c7***********@beast.euro.net...
Hi,

When I open a form I want to determine which record is the last in the
tblCases. I've created a query where I copied the SQL code.
But when I want to give the output to MyVar, the content is "Dim

strGetSQL
As String strGetSQL = "SELECT Max(tblCases.Casenummer) AS

MaxVanCasenummer "
& "FROM tblCases " & "ORDER BY Max(tblCases.Casenummer);"

But I want the value of the keyrecord which name is Casenummer

This is my code

Dim strGetSQL As String
strGetSQL = "SELECT Max(tblCases.Casenummer) AS MaxVanCasenummer " _
& "FROM tblCases " _
& "ORDER BY Max(tblCases.Casenummer);"
MyVar = strGetSQL
What am I doing wrong?


Your trying to use a SQL string as if it were a function. Since it is
between quotes it is a string in your code, nothing more. To actually
*use* SQL in code you have to create a RecordSet based on the SQL and then
pull the values you want from the RecordSet. A simplified method of doing
that is using a Domain Aggregate function which can get the value for you.

MyVar = DMax("Casenummer", "tblCases")

BTW your SQL statement is only going to retrieve a single value so the
ORDER BY is superfluous.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Nov 12 '05 #3

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

Similar topics

2
by: Nathan Sokalski | last post by:
I want to determine the operating system using ASP (or VBScript inside of ASP). I tried to get it using the Request. ServerVariables(EnvironmentVariable) method. On the web page about ASP in which...
3
by: Shahid Juma | last post by:
Hello All, This may be a trivial question, but I was wondering how can you determine if a value contains an Integer or Float. I know there is a function called IsNumeric, however you can't...
5
by: Hennie de Nooijer | last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem clear to you. SITUATION I'm building A SLA Query for a customer. This customer has an awkward way to determine the SLA results...
3
by: lucpustjens | last post by:
Hello, I want te determine the client operating system, because I need to kno the default cookie directory. If there is a way to determine the cooki directory directly, than it is also good. ...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.