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

Get the first in the row

In the part of the code shown below, is it possible for the constant
LngCustomer to get the fist number of the customers in the table
Customers
for example, if the first customerid = 4000, then to get LngCustId =
4000
Const lngCustomerID = 1

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim lngOrderID As Long
Dim strSQL As String
On Error GoTo ErrHandler

' Create a new order and obtain its OrderID
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Orders", dbOpenDynaset)
rst.AddNew
rst!Customerid = lngCustomerID
lngOrderID = rst!OrderID
rst.Update

Feb 3 '06 #1
2 1328
solar wrote:
In the part of the code shown below, is it possible for the constant
LngCustomer to get the fist number of the customers in the table
Customers
for example, if the first customerid = 4000, then to get LngCustId =
4000
No. Constants are not dynamic. They are constant.

You could do something like
Dim lngCustomerID As Long
lngCustomerID = NZ(Dmin("CustomerID","Customers"),0)
and that will retrieve the lowest customer ID. Use NZ if it's possible
that the customer table is empty.

Const lngCustomerID = 1

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim lngOrderID As Long
Dim strSQL As String
On Error GoTo ErrHandler

' Create a new order and obtain its OrderID
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Orders", dbOpenDynaset)
rst.AddNew
rst!Customerid = lngCustomerID
lngOrderID = rst!OrderID
rst.Update

Feb 3 '06 #2
Yes, it's possible.
It's not recommended, and something that changes is not a constant.

Feb 3 '06 #3

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

Similar topics

24
by: Hung Jung Lu | last post by:
Hi, Does anybody know where this term comes from? "First-class object" means "something passable as an argument in a function call", but I fail to see the connection with "object class" or...
12
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on...
3
by: Chris Tanger | last post by:
I am creating a class that has a method "Write" that I wish to make threadsafe. The method must block calling threads until the task performed in write is complete. Only 1 thread at a time can...
3
by: Chris Tanger | last post by:
I am creating a class that has a method "Write" that I wish to make threadsafe. The method must block calling threads until the task performed in write is complete. Only 1 thread at a time can...
4
by: Milan Krejci | last post by:
int first=15,latest=15; QString typ=NULL; std::map<int,std::string>::iterator i; for(i = SeznamPracovniDoby.begin(); i != SeznamPracovniDoby.end(); i++) { if (typ==NULL) typ=i->second.c_str(); if...
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
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: 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
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...
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
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...
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...
0
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...
0
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,...

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.