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

Populating ListBox in Access

Hello All,

I currently have an order form, when a record is selected and saved this should appear within the listbox below. i could get this to add but at the same time the order that i have placed from the previous order would display within the same listbox. when i only want the record from the current order that is being placed
This is what i am using...
Expand|Select|Wrap|Line Numbers
  1. Private Sub populateListbox()
  2.  Dim strSQL As String
  3.  Dim strcustomername As String
  4.  Dim rstLoans As DAO.Recordset
  5.  strcustomername = txtorderno.Value
  6.  
  7.      Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
  8.     lstOrderDetails.RowSource = ""
  9.  
  10. strSQL = "SELECTtblorder.orderno,tblorder.ProductID1,tblorder. [Clothingtype1]"     
  11. strSQL = strSQL & "FROM tblorder;"
  12.  
  13.  
  14.  
  15.     lstOrderDetails.RowSource = strSQL
  16. End Sub
This is the code that i am currently using. i am stuck plz halp!!!!
Jan 26 '08 #1
11 2350
ADezii
8,834 Expert 8TB
Hello All,

I currently have an order form, when a record is selected and saved this should appear within the listbox below. i could get this to add but at the same time the order that i have placed from the previous order would display within the same listbox. when i only want the record from the current order that is being placed
This is what i am using...

Private Sub populateListbox()
Dim strSQL As String
Dim strcustomername As String
Dim rstLoans As DAO.Recordset
strcustomername = txtorderno.Value

Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
lstOrderDetails.RowSource = ""

strSQL = "SELECTtblorder.orderno,tblorder.ProductID1,tblord er. [Clothingtype1]"
strSQL = strSQL & "FROM tblorder;"



lstOrderDetails.RowSource = strSQL
End Sub

This is the code that i am currently using. i am stuck plz halp!!!!
'I don't know the specifics, so I can just generalize:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT tblorder.orderno, tblorder.ProductID1, tblorder.[Clothingtype1] FROM tblorder WHERE tblorder.[OrderID] ="  & Me![txtOrderID]
Jan 26 '08 #2
'I don't know the specifics, so I can just generalize:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT tblorder.orderno, tblorder.ProductID1, tblorder.[Clothingtype1] FROM tblorder WHERE tblorder.[OrderID] ="  & Me![txtOrderID]
im still having problems, this is what i entered within the populate box
Expand|Select|Wrap|Line Numbers
  1. Private Sub populateListbox()
  2.  Dim strSQL As String
  3.  Dim strcustomername As String
  4.  Dim rstLoans As DAO.Recordset
  5.  'strcustomername = txtorderno.Value
  6.  
  7.      Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
  8.     lstOrderDetails.RowSource = ""
  9.  
  10.  
  11.  strSQL = "SELECT tblorder.orderno,tblorder.ProductID1,tblorder.[Clothingtype1]"
  12.  strSQL = strSQL & "FROM tblorder"
  13.  strSQL = strSQL & "WHERE tblorder.[Orderno] =" & Me![txtorderno]
  14.     lstOrderDetails.RowSource = strSQL
  15. End Sub
It allows the records to be saved but does not display anything within the listbox, if i was to take the where part of the statement out then it displays but with everyone records, hope to hear from you soon
Jan 26 '08 #3
ADezii
8,834 Expert 8TB
im still having problems, this is what i entered within the populate box
Expand|Select|Wrap|Line Numbers
  1. Private Sub populateListbox()
  2.  Dim strSQL As String
  3.  Dim strcustomername As String
  4.  Dim rstLoans As DAO.Recordset
  5.  'strcustomername = txtorderno.Value
  6.  
  7.      Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
  8.     lstOrderDetails.RowSource = ""
  9.  
  10.  
  11.  strSQL = "SELECT tblorder.orderno,tblorder.ProductID1,tblorder.[Clothingtype1]"
  12.  strSQL = strSQL & "FROM tblorder"
  13.  strSQL = strSQL & "WHERE tblorder.[Orderno] =" & Me![txtorderno]
  14.     lstOrderDetails.RowSource = strSQL
  15. End Sub
It allows the records to be saved but does not display anything within the listbox, if i was to take the where part of the statement out then it displays but with everyone records, hope to hear from you soon
Is OrderID Numeric or Text?
Jan 27 '08 #4
Is OrderID Numeric or Text?
It is currently set to Text, I have tried it now with it changed to number but still nothing is being displayed within the listbox,,
Jan 27 '08 #5
TerryDM
14
It is currently set to Text, I have tried it now with it changed to number but still nothing is being displayed within the listbox,,
Try changing the Me![txtOrderNo] to forms![frmXXXX]![txtOrderNo]. Me dosn't work in queries.
Jan 27 '08 #6
Try changing the Me![txtOrderNo] to forms![frmXXXX]![txtOrderNo]. Me dosn't work in queries.
still no luck, there must be something else that i am doing wrong and i just dont have a clue!!!!!!!
Jan 27 '08 #7
ADezii
8,834 Expert 8TB
still no luck, there must be something else that i am doing wrong and i just dont have a clue!!!!!!!
If [OrderID] is set to Text, then:
Private Sub populateListbox()
Dim strSQL As String
Dim strcustomername As String
Dim rstLoans As DAO.Recordset
'strcustomername = txtorderno.Value

Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
lstOrderDetails.RowSource = ""


strSQL = "SELECT tblorder.orderno,tblorder.ProductID1,tblorder.[Clothingtype1]"
strSQL = strSQL & "FROM tblorder"
strSQL = strSQL & "WHERE tblorder.[Orderno] =" & Me![txtorderno]
lstOrderDetails.RowSource = strSQL
End Sub

I think that it is simply a matter of Syntax, Copy and Paste the appropriate lines of code below,
substituting your Form Name for <Your Form Name>:
Expand|Select|Wrap|Line Numbers
  1. 'If OrderNo is Text
  2.   strSQL = "SELECT tblOrder.OrderNo, tblOrder.ProductID1, tblOrder.[Clothingtype1] "
  3.   strSQL = strSQL & "FROM tblOrder WHERE tblOrder.[OrderNo] = '" & Forms![<Your Form Name>]![txtOrderNo] & "';"
  4.  
  5.  'If OrderNo is Numeric
  6.   strSQL = "SELECT tblOrder.OrderNo, tblOrder.ProductID1, tblOrder.[Clothingtype1] "
  7.   strSQL = strSQL & "FROM tblOrder WHERE tblOrder.[OrderNo] = " & Forms![<Your Form Name>]![txtOrderNo] & ";"
  8.  
  9.     Me![lstOrderDetails].RowSource = strSQL
Jan 28 '08 #8
If [OrderID] is set to Text, then:
Private Sub populateListbox()
Dim strSQL As String
Dim strcustomername As String
Dim rstLoans As DAO.Recordset
'strcustomername = txtorderno.Value

Set rstLoans = dbase.OpenRecordset("tblorder", dbOpenDynaset)
lstOrderDetails.RowSource = ""


strSQL = "SELECT tblorder.orderno,tblorder.ProductID1,tblorder.[Clothingtype1]"
strSQL = strSQL & "FROM tblorder"
strSQL = strSQL & "WHERE tblorder.[Orderno] =" & Me![txtorderno]
lstOrderDetails.RowSource = strSQL
End Sub

I think that it is simply a matter of Syntax, Copy and Paste the appropriate lines of code below,
substituting your Form Name for <Your Form Name>:
Expand|Select|Wrap|Line Numbers
  1. 'If OrderNo is Text
  2.   strSQL = "SELECT tblOrder.OrderNo, tblOrder.ProductID1, tblOrder.[Clothingtype1] "
  3.   strSQL = strSQL & "FROM tblOrder WHERE tblOrder.[OrderNo] = '" & Forms![<Your Form Name>]![txtOrderNo] & "';"
  4.  
  5.  'If OrderNo is Numeric
  6.   strSQL = "SELECT tblOrder.OrderNo, tblOrder.ProductID1, tblOrder.[Clothingtype1] "
  7.   strSQL = strSQL & "FROM tblOrder WHERE tblOrder.[OrderNo] = " & Forms![<Your Form Name>]![txtOrderNo] & ";"
  8.  
  9.     Me![lstOrderDetails].RowSource = strSQL
THANKS MATE!!!!! you dont know how much i appreaciate this!!!!!
youve made my day, i was pulling my hairs out on this one!!!

Thanks again
Jan 28 '08 #9
THANKS MATE!!!!! you dont know how much i appreaciate this!!!!!
youve made my day, i was pulling my hairs out on this one!!!

Thanks again
you sort one and then another ten questions pop out.

within that code you sent me, i will have be displaying product total. so each prodcut that is added, within the listbox will be displayed the total for that item ,

for example quantity= 10 * 19.99each the total 199.99 for each line will be displayed, i could get this to work so it adds the the total for each line to the listbox.
But now i want to add the total of each line in the listbox and display it in a text box which i have called = txttotalcost

thanks again
Jan 28 '08 #10
ADezii
8,834 Expert 8TB
you sort one and then another ten questions pop out.

within that code you sent me, i will have be displaying product total. so each prodcut that is added, within the listbox will be displayed the total for that item ,

for example quantity= 10 * 19.99each the total 199.99 for each line will be displayed, i could get this to work so it adds the the total for each line to the listbox.
But now i want to add the total of each line in the listbox and display it in a text box which i have called = txttotalcost

thanks again
I must admit that I am confused as to exactly whay youe are asking. Please be more specific, and Post some actual data and the results you would like to achieve.
Jan 28 '08 #11
I must admit that I am confused as to exactly whay youe are asking. Please be more specific, and Post some actual data and the results you would like to achieve.
When a customer selects an item , say P00001, this would bring up the record for that item and then the customer selects quantity required this would multilpy the unit price by the the quantity to give a total. When the add button is pressed this would save the item within the listbox.

What i would like to know is say when a customer selects 5 items, this would display the total cost for each product within the listbox. i want to add all the totals up within the listbox and display the total within a seperate text box.
for example:

product ID, Name, quantiy, item price, totalcost
P0001 Top 5 1.00 5.00
P0002 Top 4 2.00 8.00
P0003 Top 3 1.00 3.00


i then have a text box where i want to display the total for these items within. hope this helps. im really stuck on this one!!!

hope this helps!
Jan 28 '08 #12

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

Similar topics

3
by: Broder | last post by:
Hi there, I am currently running into a somewhat weired problem and hope that this NG is able to help ;-) I have a table in a MSSQL Server in which there is one Column that stores a date. The...
1
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList...
0
by: Bill Brinkworth | last post by:
I want the user to type in part of a word, and I want to return all words from an Access word table that contains specified letters. If they were to type "fe??", it should return all words in the...
6
by: Deano | last post by:
I needed to have a listbox populated by locations which are stored in tblLocations. However I wanted an "All locations" entry to be at the top of the listbox. This is not in the tblLocations. The...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: P K | last post by:
I have a listbox which I am populating on the client (it contains a list of dates selected from calender). The listbox is a server control. When I get to the server after postback by selecting an...
0
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my...
5
JustJim
by: JustJim | last post by:
Well this has been fun, but I now elect to "phone a friend" I have an Access application in which the operator can enter/choose the name of a training course and enter the number of teachers from...
15
by: NasirMunir | last post by:
I am trying to populate a listbox from another listbox on a access form. My first listbox has names of tables on a linked odbc databse. I am trying to display the tuples of the table in the second...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.