473,625 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to update a combo box using a command button or report event

24 New Member
I have a form with a subform containing the combo box I want to update. I have a command button in the header of the main form that launches a report in print preview mode. I want to update the combo box from 'New' to 'Confirmed' when the report is generated. I have tried the following code in both the buttons on_click event and in the reports on_close event (security is set to trust the db)
Expand|Select|Wrap|Line Numbers
  1. Forms![Transactions]![Transaction Details Subform].[Form]![OrderStatusID]="1"
There are no errors but it does not work.
Can someone help.
NB: There is a one-to-many relationship between the underlying tables of the main and sub forms so multiple instances of the combo box may appear on the form - All need to be updated.
Jun 13 '09 #1
12 2133
DonRayner
489 Recognized Expert Contributor
Your syntax is slightly off.
Expand|Select|Wrap|Line Numbers
  1. Forms![Transactions]![Transaction Details Subform].[Form]![OrderStatusID]="1"
  2.  
should be

Expand|Select|Wrap|Line Numbers
  1. Forms![Transactions].Form![Transaction Details Subform]![OrderStatusID]="Confirmed"
  2.  
Jun 15 '09 #2
NeoPa
32,567 Recognized Expert Moderator MVP
Can you perhaps share with us how this ComboBox is set up Richard?

We don't really have enough info to determine what your problem may be. .RowSource, .ColumnCount, .ColumnWidths & .BoundColumn properties would be most helpful to start with.
Jun 15 '09 #3
NeoPa
32,567 Recognized Expert Moderator MVP
@DonRayner
I'm sorry Don. I feel you may be mistaken here.

Check out Referring to Items on a Sub-Form. The .Form property is relative to the SubForm control.
Jun 15 '09 #4
Richard Penfold
24 New Member
Many thanks for the help so far.
NeoPa
The Combo Box control details are as follows:
Control Source = Transactions.Or derStatusID
Row Source = SELECT [Order Status].ID, [Order Status].OrderStatus FROM [Order Status];
Format: Column Count = 2: Column Width = 0cm;2.5cm.

All
I have implemented the code suggested with one minor change as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Close()
  2. Forms![Transactions]![Transaction Details Subform]![OrderStatusID] = 2
  3. End Sub
This code updates one instance of the control on my form. There can be multiple instances however. As a simplified representation, the form looks like this...
Expand|Select|Wrap|Line Numbers
  1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  2. Main Form
  3. CustomerName : OrderNumber : Date : Comments
  4.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  5. Sub Form
  6. New: Qty : OrderCode : Description  
  7. New: Qty : OrderCode : Description  
  8. New: Qty : OrderCode : Description  
  9. ...etc
  10. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Where 'New' is the default value of the 'OrderStatusID' control I want to update

When I run the code (close the report) I get this...
Expand|Select|Wrap|Line Numbers
  1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  2. Main Form
  3. CustomerName : OrderNumber : Date : Comments
  4.  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  5. Sub Form
  6. Confirmed  : Qty : OrderCode : Description  
  7. New        : Qty : OrderCode : Description  
  8. New        : Qty : OrderCode : Description  
  9. ...etc
  10. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A customer may request many items on any one order. - I want to confirm all of them at once.
Jun 16 '09 #5
NeoPa
32,567 Recognized Expert Moderator MVP
Ah. That's quite a different question then (at least a fundamentally different answer now the question is clearer).

For this you will want instead, to update the records in the table (using some simple SQL) and then call a .Requery of the subform.

We don't have the details of any filtering or linking that restricts the data on your subform, but you will need to design SQL to reflect the same records in your update query (SQL).

If you need help with this then please reply including the info we would need to be able to show this for you.
Jun 18 '09 #6
Richard Penfold
24 New Member
Thanks NeoPa. I'll give it a go myself over the weekend and let you know the outcome.
Jun 18 '09 #7
NeoPa
32,567 Recognized Expert Moderator MVP
Please do Richard.

Good luck :)
Jun 19 '09 #8
Richard Penfold
24 New Member
Hi,
After much brain wracking I have to admit defeat. Can you tell me what's wrong with this...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Close()
  2. Update [Transaction Details] Set OrderStatusID = 2
  3. WHERE ((([Transaction Details].TransactionID) = [Forms]![Transactions]![Transaction Details Subform].[Form]![TransactionID]))
  4. End Sub
I just get a syntax error.
I have tried various combinations of bracket types and quote marks. I also tried renaming the table to remove the space - Still no-go.
Jun 22 '09 #9
NeoPa
32,567 Recognized Expert Moderator MVP
Yes. I can.

Fundamentally you are trying to execute SQL code as VBA code.

I'll have a look at it and see what I can do, but you need to create your SQL string first using VBA, then pass that string to be executed as SQL.
Jun 22 '09 #10

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

Similar topics

1
2261
by: Maria Joao | last post by:
I have two synchronized combo boxes and after the selection of the desired record, I need the user to open the related report, by pressing a button. My problem is that a combo box doesn't update do the first one. The record are correct, but the first one is always from the last selection. How can I update the second combo box? Thanks
4
1636
by: Alex | last post by:
I have searched the boards but I have not found what I am looking for yet. I have a form with two combo boxes. When the user makes a selection in both of the combo boxes the information will look through two tables and return the appropriate matches. This will be very small scale at the beginning but once I get everything working it will include more tables and dozens of matches to be returned. I would like the information to print...
2
1902
by: Ray Todd Jr | last post by:
I have created form, query and report. In the form I have a Combo Box which pulls the search criteria (SaleStatus) from one of my tables. When I select a status and click on the search button it should run the query and then preview the report. The form is an unbound form with the row source type set to table/query. The row source is a select statement pulling the data from the table. The Name of the combobox is SaleStatus.
14
4957
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons for things like delete, save, edit, cancel buttons - in the footer, or on the form detail section? 2. If in the footer, how do you add them to the tab order?
2
17711
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
6
12465
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main form called ProjectsForm. This form has several fields to enter data. I have a query that is called Owner Query. This query contains the fields IDNumber.Projects2 Team.Projects2 and Owner.OwnerName getting information from tables. On the...
2
2799
by: ndeeley | last post by:
Hello, I need to create a command button to print a report in Preview mode using the criteria from a combo box. The combo box is unbound and holds a list of clients. I need the user to select the client, then when the button is hit the report lists all the records for that client. I can write a script which prints a single record from a report, which is here: Dim strReportName As String Dim strCriteria As String
3
5722
by: gmazza via AccessMonster.com | last post by:
Hi there, I am trying to run a report using a parameter for where the user chooses a month from a combo box. Then on the report, I want it to compare the month to a date field and choose only those dates with the month chosen from the parameter form. Basically, its to see who's birthdays are coming up. So on the parameter form you choose November, so then I want the report to display all the kids who's birthdays are in November. Any help...
9
1841
by: sparks | last post by:
Right now I had to build a report that allowed the people to check for gross outliers in their data input. short I am looking at 2.5* std dev + - anyway I used 2 dummy variables in the query the report is tied to. start date and end date. This pops up an input box for these values and they put in 11/01/08 and 11/31/08 and it runs the report showing the outliers. I watched and everyone is looking at month not date Now I was thinking...
0
8259
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
8637
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
8358
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
8502
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...
0
7188
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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
2
1504
bsmnconsultancy
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...

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.