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

Need help getting values to change in a list box.

I am developing an order tracking database, which to keep this explanation simple, consists of 'Orders' table, 'Order Details' table, 'Deliveries' table & 'Inventory' table.
There are one-to-many relationships from Orders to 'Order Details, Orders to Deliveries and Orders to Inventory.
I have forms to enter and track customer orders and inventory transactions; these work fine but I am having difficulty getting a list-box control to work the way I want on the deliveries form.
I have created a bound split form using the forms wizard. The main form is bound to Orders and the subform bound to Inventory. The intention is to pick from Inventory, items for delivery.
I have added a list-box to the main form to display item order code and quantity from the Order details table. The query behind the list-box has a criterion to select from Order Details table where order number from Orders table equals the order number displayed in a text-box on the form. The difficulty I have is that this list-box does not update when I move between orders - It shows only the first Order Details data. Yet I have other text-boxes on the main form bound to the same Order Details table that do work as expected. Can someone help me get this part of the form working please.
Jan 15 '09 #1
12 1872
puppydogbuddy
1,923 Expert 1GB
You did not provide any of your code, so I am guessing on this and using illustrative object names. What I am telling you to do is requery the listbox (located on the main (parent) form) when you move between orders.

Expand|Select|Wrap|Line Numbers
  1. Private Sub OrderNumber_Change()
  2. Me.Parent.YourListbox.Requery
  3. End Sub
  4.  
Jan 15 '09 #2
I did not post my code in case it lead people astray - I was hoping for an answer to the problem, not a fix for my clumsy code. I tried the code you provided - It looks like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub OrderNumber_Change()
  2. Me.Deliveries.List27.Requery
  3. End Sub
My code was similar
Expand|Select|Wrap|Line Numbers
  1. Private Sub OrderNumber_Change()
  2. Me.List27.Requery
  3. End Sub
The code is attached as an event to the OrderNumber text box. Neither of them work. There are no errors, no change in the list box, it just seems to ignore the code. Where do we go from here?
Jan 16 '09 #3
puppydogbuddy
1,923 Expert 1GB
At this point, I think the most likely reason the requery did not work is that the syntax is incorrect. You stated that the listbox is on the main form, which I assume is named deliveries. If the order form is a subform of the main form and the code is placed behind the Ordersubform, the syntax would be as follows:
Private Sub OrderNumber_Change() 'place code behind the OrdersSubform
Me.Parent.List27.Requery
End Sub

If this does not work, please list your forms and subforms by name, and state which one has the listbox and which one has the requery code.
example
MainForm Deliveries (has listbox)
Subform1 Orders (has requery code)
Subform2
Something else ....you need to place a control break in yourOrderNumber_Change proc to determine if it is firing.
Jan 17 '09 #4
Thanks for staying with this,,, In response to your last posting:
Main Form is named Deliveries
Main Form is bound to Transactions table
Main Form has Order Number text box named 'TransactionReference'
Main Form has Unbound list box named 'List27'


Subform is named 'Deliveries Subform'
Subform is bound to Inventory table
Jan 18 '09 #5
puppydogbuddy
1,923 Expert 1GB
Richard,
I believe the code below should work, provided that the TransactionReference_Exit() event is firing. I assume that this textbox is unbound, and therefore you can not use the change or afterUpdate events to fire the requery code. It should fire in the textbox's exit event if you are entering the OrderNumber into the TransactionReference textbox. If you do not enter the OrderNumber in that textbox, please tell me where it is entered.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TransactionReference_Exit()
  2. Me.List27.Requery
  3. End Sub
  4.  
Jan 18 '09 #6
Thanks again... I have tried the new code but still no joy.
To recap and expand on a couple of things...
The 'Deliveries' main form is bound to and reads data from the 'Transactions' table.
As I move from record to record, the order number (entered previously) in the 'TransactionReference' (bound) text box, changes.
The 'TransactionReference' text box is bound to the 'Transactions' table, 'TransactionReference' field.
'List27' (unbound) reads 'OrderCode' from the 'Order Codes' table and 'QtyOrdered' from the 'Transaction Details' table.
The 'Transactions' table has a one-to-many relationship with 'Transaction Details'
'Transaction Details has a one-to-many relationship with 'Order Codes'.

The criteria placed on 'List27 query is to select based on the value in the 'TransactionReference' text box on my form
The query code is listed here:
Expand|Select|Wrap|Line Numbers
  1. "
  2. SELECT Transactions.TransactionReference, [Transaction Details].OrderCodeID, [Order Codes].OrderCode, [Transaction Details].QtyOrdered
  3. FROM Transactions INNER JOIN ([Order Codes] INNER JOIN [Transaction Details] ON [Order Codes].ID = [Transaction Details].OrderCodeID) ON Transactions.ID = [Transaction Details].TransactionsID
  4. WHERE (((Transactions.TransactionReference)=[Forms]![Deliveries]![TransactionReference]));
  5. "
I have created a separate query using the code above and tested it by running the query after I move to the next record and the test query works just fine.

I think your code is good and I suspect that the event procedures are not firing (same on different computers). How can I test if they are? Your previous post said to put a control break into the code - I do not know how to do this. If we establish that the event procedures are not firing, how do we fix it?
Jan 19 '09 #7
I have taken a further look at event procedures in MSDN and I find that I have to type something into a text field before the 'On Change" event (or many other) works. After stumbling around with different event types I arrived at this:
Set the 'On Got Focus' event...
Expand|Select|Wrap|Line Numbers
  1. Private Sub TransactionReference_GotFocus()
  2. Me.List27.Requery
  3. End Sub
This will work but only if you click in the TransactionReference text box after moving between records. So I added the following:
Set the main form 'On Current' event...
Private Sub Form_Current()
Me.TransactionReference.SetFocus()
End Sub

This forces the focus to return to the TransactionReference text box after moving between records, which in turn re-queries the list box

Seems to work but is it the right solution? - Is there something more elegant that I should be using?
Jan 19 '09 #8
puppydogbuddy
1,923 Expert 1GB
Richard,

The fact that you are not able to fire the change and AfterUpdate events is why I was trying to tell you in my previous post to try the Exit event. Quote from my previous post:"It should fire in the textbox's exit event if you are entering the OrderNumber into the TransactionReference textbox. If you do not enter the OrderNumber in that textbox, please tell me where it is entered."

My question remains>>>>>> where/how do you orignate the change in the OrderNumber...via the listbox or via the textbox or how ??? The answer to this question will help determine if there is a more elegant solution. Even if there is a more elegant solution, congrats to you for finding a work around.
Jan 19 '09 #9
Seems like I didn't do a good enough job explaining how this database works. Just shows we need to test understanding at every stage - And thats with us using a common language.
The database has 3 functions
1 - Order Processing
2 - Inventory management
3 - Deliveries register
A customer order number is entered during order processing. This number is entered to the 'TransactionReference' field of the 'Transactions' table via an 'Orders' form.
When we come to deliveries, the 'TransactionReference' field is displayed on the 'Deliveries' form. The number in the text box on the 'Deliveries' form changes as I move from record to record but it is not entered or overtyped here.
Jan 19 '09 #10
puppydogbuddy
1,923 Expert 1GB
Richard,
I believe this is the elegant solution you want. Place this code in the current event of the [Deliveries Subform], not the Main Form. It should force a requery as you move from record to record on the [Deliveries Subform]. I am assuming that [Deliveries Subform] is the name of the source object <a form> that is embedded in the subform control. The subform container is on the main form and the subform source object is the form that is usually referred to as the subform. Often the subform control on the main form and the subform source object have the same name, but not always....

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()                    'current event of [Deliveries Subform]
  2. Me.Parent.List27.Requery 
  3. End Sub 
  4.  
Jan 20 '09 #11
The list box is now working well. Thanks for your time and patience.mate.
Please keep your eyes open for future postings from me. Never having developed a database before, I am sure to hit more submerged logs as I try to sail these (for me) uncharted waters.
Jan 20 '09 #12
puppydogbuddy
1,923 Expert 1GB
Richard,
You are welcome. I am glad your list box problem is resolved. I am sure I'll see you around. Take care.

pDog
Jan 20 '09 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
5
by: James Baker | last post by:
I have a form that has a dropdown list that will cause a post to the same page when it's changed. The problem I'm running into is that all of the controls reset to their default values (obviously...
7
by: Rodney King | last post by:
Hi, I have developed an ASP page which dynamically displays a list of checkbox options based on a SQL statement. Here is my code: <div style="OVERFLOW:auto; Height: 150px"> <table> <% dim...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: Mark | last post by:
Hi, I have an aspx page, that in the PageLoad sub, gets values from a specific record in a database as where the record id is retrieved from the querystring. Thesee values are then used to...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
6
by: nephish | last post by:
Hey there all. i have been looking to simplify my huge website that i wrote while learning php. now its a spaghetti mess. So, i wanted to simplify it. Now, i see the functionality that defining...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
15
RMWChaos
by: RMWChaos | last post by:
In my ongoing effort to produce shorter, more efficient code, I have created a "chicken and egg" / "catch-22" problem. I can think of several ways to fix this, none of them elegant. I want my code...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.