473,805 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listbox record count help!

hi guys i have form with a listbox . The listbox is coming from a query that
gets all passengers(colu mn 1 in listbox) and destinations(co lumn 3) . so you
have repeting rows of passengers since they could have up to three
destinations. Then the user has to select a row in the list box , double
click even in my listbox i have to sql query to delete the currect item
selected (passenger with destination). this works fine. however i need to put
some kind of code so then when there is a recordcount of 1 of the current
destination, then you can't delete. Meaning that each passenger must have at
least one destination. I already put in the table not to allow any nulls in
for destinations, but still it lets you delete the last destination.

this is what i have so far:
Private Sub cmdDelete_Click ()

Dim dbs As DAO.Database
Dim strSQL As String
If Me.List33.Recor dset = 1 Then
MsgBox " you must have at least one Destination "
DoCmd.CancelEve nt
Set dbs = CurrentDb
If MsgBox("Are you sure you want to delete the selected Destination?",
vbYesNo) = vbYes Then

strSQL = "UPDATE tblPassengerDes tination Set Dest_Status = ""Inactive" " WHERE
ID = " & List33.Column(0 )
DoCmd.RunSQL strSQL
MsgBox "Your Destination has been deleted"
Me.List33.Reque ry

Else
DoCmd.CancelEve nt

End If

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 3 '06 #1
1 3626

"rsbutterfl y16 via AccessMonster.c om" <u21410@uwewrot e in message
news:673a04a543 673@uwe...
hi guys i have form with a listbox . The listbox is coming from a query
that
gets all passengers(colu mn 1 in listbox) and destinations(co lumn 3) . so
you
have repeting rows of passengers since they could have up to three
destinations. Then the user has to select a row in the list box , double
click even in my listbox i have to sql query to delete the currect item
selected (passenger with destination). this works fine. however i need to
put
some kind of code so then when there is a recordcount of 1 of the current
destination, then you can't delete. Meaning that each passenger must have
at
least one destination. I already put in the table not to allow any nulls
in
for destinations, but still it lets you delete the last destination.

this is what i have so far:
Private Sub cmdDelete_Click ()

Dim dbs As DAO.Database
Dim strSQL As String
If Me.List33.Recor dset = 1 Then
MsgBox " you must have at least one Destination "
DoCmd.CancelEve nt
Set dbs = CurrentDb
If MsgBox("Are you sure you want to delete the selected Destination?",
vbYesNo) = vbYes Then

strSQL = "UPDATE tblPassengerDes tination Set Dest_Status = ""Inactive" "
WHERE
ID = " & List33.Column(0 )
DoCmd.RunSQL strSQL
MsgBox "Your Destination has been deleted"
Me.List33.Reque ry

Else
DoCmd.CancelEve nt

End If

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200610/1
From what I understand you want to make sure the passenger doesn't get
deleted totally form the list. If so make a query that counts how many times
the passenger is on the list and if record count less 2 cancel his action.
Does me.list33.recor dset include your whole list? Tip: after running your
query sometimes you need to do a movefirst and movelast (any order) to get
an accurate count using the property recordcount.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Oct 3 '06 #2

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

Similar topics

6
7875
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
9
7029
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
5
6346
by: Lisa | last post by:
Hello, I am new to using recordsets, and i am completly stuck with this one. I am trying to use a multi select list box to write records to a table. Something in my code is causing the same record to be written over and over, for example if I have 4 items selected, it writes the same item 4 times in my table. Here is my code.
3
5743
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a listbox looks up data from a table and fills the listbox. I have a stored procedure that looks up the selected values and tries to show them as selected in the listbox. My FOR NEXT LOOP gets stuck on one record in the datatable. There are 4 records in the datatable and only the first one is selected. It never moves past the first record. MyCommand.Fill(dsCom, "tblCommRealtorAssociation") ...
3
2301
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
3
2003
by: Angel Blue01 | last post by:
I have a form with a binding navigator that draws from a database via drag-and-drop-created controls. I'm filling a listbox with the results of a query. The listbox contains data related to the record that the user is viewing but cannot be databound because other events and user input are needed when the user selects an item from the listbox. Each time the user clicks the binding navigator to move to the next record I have this: <code>
1
4034
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
45
6900
by: angelicdevil | last post by:
i have 2 tables 1 is status_type with field name status and other is users with field username and status now i want that the first listbox lists all status from status type ( this i have achieved with php ) and based on selection of the value in listbox 1 the corresponding data in table users be loaded in listbox 2 . i have achieved this by using a button in php but i want tht it operate without submit button and no page refreshing ...
4
1944
by: onyris | last post by:
-------------------------------------------------------------------------------- Hi guys , have 2 questions if anyone can help me . first - have a form which displays all the records i have in my database , and a search box for the user to search for a specific one . On the search button, i run a macro which opens another form with only the records found based on the search. So far so good :). Now one the second form first record found...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.