Can someone help on this problem.
I have a combo box of, say three Items, selected from a table that
serves as the lookup: E.g. 1 Earth, 2 Pine, 3 Earth Grave
The combo box is on the subform.
If the user selects any of the item, that item so selected should not
appear in the list again; or
The user should be warned about previous selection.
I dont want the user accidentally selecting the same item out of
error.
Will be grateful if someone can give me a solution. 6 2909
You will need a way to indicate that a particular item has been chosen, and
requery the Combo (assuming you are using a Query for the Row Source) to
create a new list. You'll have to determine the scope of this "used, don't
use again" rule and code accordingly... your code will be different if the
scope is "this record", "this session", "this date", or "ever and always".
If you are choosing from a Value List, then it is totally under your
control, and you can provide code in the AfterUpdate event of the Combo to
replace the list after you eliminate the item that was chosen.
Larry Linson
Microsoft Office Access MVP
<he************ @gmail.comwrote in message
news:58******** *************** ***********@26g 2000hsk.googleg roups.com...
Can someone help on this problem.
I have a combo box of, say three Items, selected from a table that
serves as the lookup: E.g. 1 Earth, 2 Pine, 3 Earth Grave
The combo box is on the subform.
If the user selects any of the item, that item so selected should not
appear in the list again; or
The user should be warned about previous selection.
I dont want the user accidentally selecting the same item out of
error.
Will be grateful if someone can give me a solution.
Thank you LARRY,
I quite understand the logic, but sincerely if you can give me an
example.
I am actually using a query as the source, and i want it on the
session i am currently working.
Will be glad if u could help.
On your table have a Field "Selected" as a Yes/No Type
On the open of the form, change all the "Selected" to False
On the close of the form (just to make sure) change all the "Selected" to
False
Your combo box needs a sql somethin like
SELECT Material, MaterialID, Selected FROM MyTable WHERE Selected =False;
2 Columns
Bound Column Column 2
Column Width 5cms; 0 cms
The Update of the Comboboc ("Combo2"
Option Compare Database
Option Explicit
Private Sub Combo2_AfterUpd ate()
Dim Mydb As Database
Dim MySet As Recordset
Dim Criteria As String
Set Mydb = CurrentDb
Set MySet = Mydb.OpenRecord set("CoInfo")
Criteria = "MaterialID = " & CLng(Combo2)
With MySet
Do Until !MaterialID = CLng(Combo2)
.MoveNext
Loop
.Edit
!Selected = True 'Then it wont be seen next time
.Update
.Close
Set MySet = Nothing
End With
Combo2.Requery
End Sub
HTH
Phil
<he************ @gmail.comwrote in message
news:bc******** *************** ***********@l64 g2000hse.google groups.com...
>
Thank you LARRY,
I quite understand the logic, but sincerely if you can give me an
example.
I am actually using a query as the source, and i want it on the
session i am currently working.
Will be glad if u could help.
Thank you Phil
However, I still seem to have a problem. After I select an Item, the
item selected does not remain in view in the combo box as usual. It
actually removes the item from the list though. Here is the code in
the After Update
Private Sub Item_AfterUpdat e()
Dim Mydb As Database
Dim MySet As Recordset
Dim Criteria As String
Set Mydb = CurrentDb
Set MySet = Mydb.OpenRecord set("L_tbItem")
Criteria = "ItemID = " & CLng(Item)
With MySet
Do Until !ItemID = CLng(Item)
.MoveNext
Loop
.Edit
!Selected = True 'Then it wont be seen next time
.Update
.Close
Set MySet = Nothing
End With
Item.Requery
End Sub
And the sql on the combo Item is
SELECT L_tbItem.Item, L_tbItem.ItemID , L_tbItem.Rate,
L_tbItem.Select ed FROM L_tbItem WHERE (((L_tbItem.Sel ected)=No));
Item is what should be displayed on the combo box after selection.
ItemID is the PK of the table
Rate is associated with an Item which automatically updates the rate
column in the table.
Is there anything I am missing?
Will appreciate if you can help.
Well you gave that ias one alternative in your original post.
If you want to still see the item, remove the "WHERE
(((L_tbItem.Sel ected)=No))" from the SELECT statement (note that the
semicolon remains)
Change the column count from 2 to 3
Then add the following code on the BeforeUpdate
Private Sub Item_BeforeUpda te(Cancel As Integer)
If Item.Column(2) = True Then
MsgBox "This has already been selected", vbInformation
Cancel = True
End If
End Sub
Phil
<he************ @gmail.comwrote in message
news:52******** *************** ***********@d45 g2000hsc.google groups.com...
Thank you Phil
However, I still seem to have a problem. After I select an Item, the
item selected does not remain in view in the combo box as usual. It
actually removes the item from the list though. Here is the code in
the After Update
Private Sub Item_AfterUpdat e()
Dim Mydb As Database
Dim MySet As Recordset
Dim Criteria As String
Set Mydb = CurrentDb
Set MySet = Mydb.OpenRecord set("L_tbItem")
Criteria = "ItemID = " & CLng(Item)
With MySet
Do Until !ItemID = CLng(Item)
.MoveNext
Loop
.Edit
!Selected = True 'Then it wont be seen next time
.Update
.Close
Set MySet = Nothing
End With
Item.Requery
End Sub
And the sql on the combo Item is
SELECT L_tbItem.Item, L_tbItem.ItemID , L_tbItem.Rate,
L_tbItem.Select ed FROM L_tbItem WHERE (((L_tbItem.Sel ected)=No));
Item is what should be displayed on the combo box after selection.
ItemID is the PK of the table
Rate is associated with an Item which automatically updates the rate
column in the table.
Is there anything I am missing?
Will appreciate if you can help.
On Aug 1, 8:22*am, "Phil Stanton" <p...@myfamilyn ame.co.ukwrote:
Well you gave that ias one alternative in your original post.
If you want to still see the item, remove the "WHERE
(((L_tbItem.Sel ected)=No))" from the SELECT statement (note that the
semicolon remains)
Change the column count from 2 to 3
Then add the following code on the BeforeUpdate
Private Sub Item_BeforeUpda te(Cancel As Integer)
* * If Item.Column(2) = True Then
* * * * MsgBox "This has already been selected", vbInformation
* * * * Cancel = True
* * End If
End Sub
Phil
<henry.onovw... @gmail.comwrote in message
news:52******** *************** ***********@d45 g2000hsc.google groups.com...
Thank you Phil
However, I still seem to have a problem. *After I select an Item, the
item selected does not remain in view in the combo box as usual. *It
actually removes the item from the list though. *Here is the code in
the After Update
Private Sub Item_AfterUpdat e()
* *Dim Mydb As Database
* *Dim MySet As Recordset
* *Dim Criteria As String
* *Set Mydb = CurrentDb
* *Set MySet = Mydb.OpenRecord set("L_tbItem")
* *Criteria = "ItemID = " & CLng(Item)
* *With MySet
* * * *Do Until !ItemID = CLng(Item)
* * * * * *.MoveNext
* * * *Loop
* * * *.Edit
* * * *!Selected = True * * * * * *'Then it wont be seen next time
* * * *.Update
* * * *.Close
* * * *Set MySet = Nothing
* *End With
* *Item.Requery
End Sub
And the sql on the combo Item is
SELECT L_tbItem.Item, L_tbItem.ItemID , L_tbItem.Rate,
L_tbItem.Select ed FROM L_tbItem WHERE (((L_tbItem.Sel ected)=No));
Item is what should be displayed on the combo box after selection.
ItemID is the PK of the table
Rate is associated with an Item which automatically updates the rate
column in the table.
Is there anything I am missing?
Will appreciate if you can help.
Thank you Phil
Everything is working perfectly well.
Though my client insists on having the item removed in the list.
But we are satisfied with the way it is. This way no two items can be
selected because of the
Cancel = True
However, if there are five items, and this selection is happening on
the sixth record, after all five has been entered, user needs to press
Esc or delete the record.
Thank you for your help. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jon |
last post by:
I am trying to create a "front end program" to an oracle database and am
using visual basic .net to create the program that will accomplish this.
What i need to do and what i can't find is the code to create a drop down
list with 4 values and one (null) set as a default. I am sorry if i just
can't find the correct article here, i really did try to search for it, so if
anyone could help me i would appreciate it.
|
by: pdb |
last post by:
I want to make something so I can make a grocery list easy and just print it
off. I am guessing I would have a drop down list, which would be a list of
tables, then select item from the table. For example, first I want milk, so
in the first drop down list i choose dairy, then select milk. Is there a way
to do this and have an add button so it adds it to a list (report)?
Thanks Paul
|
by: Paul |
last post by:
Hi,
When should I use a list (in table properties: like
Ford;Mercedes;BMW;Audi )
and when should I use a lookup table??
And second question: IF I use a lookup table, should I always make a
relation (1-to-many) in my relation scheme?
Any help is greatly appreciated, I'm a bit puzzled.
|
by: g18c |
last post by:
Hi, i have a class which has a property which is a list of items. I
want to be able to set this item list from a set of items (in this case
list2 as shown in the code below) from a drop down combo box. This will
allow me to enter valid items in a seperate form, then when adding a
new Class1 object i can select from one of the valid Class2 items in
the dropdown list. I hope this makes sense, i have got partway there
but i have lost...
|
by: Bremanand |
last post by:
Hi am doing my project using Vb 6.0 with ms-access..
am using combo box to select the item by the user..
if the user selecting the item in the combo box without using mouse.
My problem is,
While they are typing the first letter of the item,automatically the corresponding items which starts by that letter should be displayed under the combo box.similarly for the second ,third letters n so on....so that the user can select the items...
| |
by: JweldonH |
last post by:
My issue probably has a simple answer.
I want to limit a populated combo box to items that are NOT in use in another table. I have a Table with a field that looks up values from another table via a combo box. As I select items from that combo box list, I would like for the list to automatically remove that selection from the combo box list so it wont be availble to select. (And have it add any item that I change or remove from the tabe) The...
|
by: Kevin Wilcox |
last post by:
In Access 2003 I have a continuous form with a combo. I'm trying to find a way to change the displayed values of the combo depending on whatever value was selected in the combo in the previous record, whilst also displaying whatever value was seelcted in previous records, i.e. record one might have 5 as the value, which means the combo in the next record would include items 3,4 and 6; if the user then selects item 6, the next record would allow...
|
by: sree078 |
last post by:
I've a list of items which I bound to multiple combo boxes.
In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo boxes...How should I do that...
As when I'm trying to add an item...it is being shown in all the combo boxes.
private void FillMethod()
{
BindingSource bs = new BindingSource();
BindingSource bs1 = new BindingSource();
...
|
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,...
|
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...
|
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...
| |
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |