473,473 Members | 1,906 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting data from a table not bound to a form

84 New Member
I created a form that contains a list box. The list box value comes from a table.
The list box is Titled XML_NODE. When the form is open, the list box displays the value from the table 255.255.255.0. I want to pass the value from the list box to a command button. The command button will run a batch file that will use the XML_NODE information. I can get the batch file to accept the XML_NODE value if the operator selects it on the form. Is there a way to get the list box value to pass to the command without having the operator select it?

below is the command I am trying to run

"c:\List_Clients.bat " & Me!XML_NODE
Mar 28 '07 #1
13 1614
Rabbit
12,516 Recognized Expert Moderator MVP
I created a form that contains a list box. The list box value comes from a table.
The list box is Titled XML_NODE. When the form is open, the list box displays the value from the table 255.255.255.0. I want to pass the value from the list box to a command button. The command button will run a batch file that will use the XML_NODE information. I can get the batch file to accept the XML_NODE value if the operator selects it on the form. Is there a way to get the list box value to pass to the command without having the operator select it?

below is the command I am trying to run

"c:\List_Clients.bat " & Me!XML_NODE
You don't even need the listbox, if you don't even want the operator to have to select it, then you can just pass the information directly from the table to what you want to run in the On Open event.
Mar 29 '07 #2
sesling
84 New Member
You don't even need the listbox, if you don't even want the operator to have to select it, then you can just pass the information directly from the table to what you want to run in the On Open event.
I assume this would be on the command button. I already have an OnClick event that will launch the batch file. Can the command button have more than one event? Can i add the table entry directly to the OnClick event? Is so, How would it be added?
Mar 29 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
If you don't need to let the operator decide when to run the code, then you don't even need a command button. You can just put all the code in the On Load or On Open event of the form.
Mar 29 '07 #4
sesling
84 New Member
If you don't need to let the operator decide when to run the code, then you don't even need a command button. You can just put all the code in the On Load or On Open event of the form.

I am sorry. I don't think my original post accurately outlined my issue. I created a form that has several different list boxes. The data contained in those boxes are used by the operator to select a sequence. I created a command button that will launch a Batch file using the selected sequence. What I am trying to do is create a table that will contain several XML_Nodes. I want to pass the node information along with some of the list box info into a batch file. Our company does not want the node information listed on the screen and my boss does not want it hard coded into the command line in case the Node information needs to be changed. I figured If I stored the values in a table I could get the value and pass it into the command line. This way I would just have to change the table values if necessary versus changing the command parameters. I know I could mask the value in the list box but again my hands are tied because I cannot change the form any more. Is there anything I could do to pass the table data to the form so it could be used on the command line?
Mar 29 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Why can't you change the form?

Well, you can use a DLookup("[Field Name]", "[Table Name]", "WHERE clause") to look up what you want from another table.

There WHERE clause is built like the SQL WHERE except you leave out the word WHERE. You don't need it if you only have one record in the table.
Mar 29 '07 #6
sesling
84 New Member
Why can't you change the form?

Well, you can use a DLookup("[Field Name]", "[Table Name]", "WHERE clause") to look up what you want from another table.

There WHERE clause is built like the SQL WHERE except you leave out the word WHERE. You don't need it if you only have one record in the table.
In answer to your question Management does not want any additional changes to the screen. thx for the DLookup function. Is there a way to use DLookup to retreieve more than one item from the table?
Mar 29 '07 #7
Rabbit
12,516 Recognized Expert Moderator MVP
No, it can only look up one thing at a time. You'll have to use multiple DLookup to look up multiple items.
Mar 29 '07 #8
sesling
84 New Member
No, it can only look up one thing at a time. You'll have to use multiple DLookup to look up multiple items.
Would I create a statement like this in the OnOpen Event for the form

Dim VarX
Dim VarY

VarX = DLookup("XML_Node",XML_TABLE,ID=1)
VarY = DLookup("XML_Node",XML_TABLE,ID=2)

And if so, how could I pass the VarX and VarY values into my command button on the form? I have tried with just VarX and the value for VarX is not being passed to the command line. Below is the statement I am using

stAppName = "c:\SubmitCommands.Bat " & "cmdfile=cfg/app/Reports.xml " & "PN1=" & VarX
Mar 29 '07 #9
Rabbit
12,516 Recognized Expert Moderator MVP
Would I create a statement like this in the OnOpen Event for the form

Dim VarX
Dim VarY

VarX = DLookup("XML_Node",XML_TABLE,ID=1)
VarY = DLookup("XML_Node",XML_TABLE,ID=2)

And if so, how could I pass the VarX and VarY values into my command button on the form? I have tried with just VarX and the value for VarX is not being passed to the command line. Below is the statement I am using

stAppName = "c:\SubmitCommands.Bat " & "cmdfile=cfg/app/Reports.xml " & "PN1=" & VarX
Close, you need to put quotes around XML_Table and ID=1/2 as well.
Expand|Select|Wrap|Line Numbers
  1. VarX = DLookup("XML_Node","XML_TABLE","ID=1")
Mar 29 '07 #10
sesling
84 New Member
Close, you need to put quotes around XML_Table and ID=1/2 as well.
Expand|Select|Wrap|Line Numbers
  1. VarX = DLookup("XML_Node","XML_TABLE","ID=1")
I did that and I am still not seeing the VarX and VarY being passed into my command event. Do the VarX and VarY need to be public variables? I cannot understand why the value won't pass to the command line. There must be I am missing. Here are the steps I followed.

I opened the form is design view
I selected properties
I changed properties from Detail to Form
In the On Open event I placed the statements above with the correct "" added. See below

Private Sub Form_Open(Cancel As Integer)
Dim VarX
Dim VarY
Dim VarZ

VarX = DLookup("VNODE", "SSS_AOA_XML", "ID=1")
VarY = DLookup("PNODE", "SSS_AOA_XML", "ID=1")
VarZ = DLookup("SERVICE", "SSS_AOA_XML", "ID=1")

End Sub

I then went to the command button and added the variable to the statement contained in the OnClick event. See Below

stAppName = "c:\SubmitCommands.Bat " & "cmdfile=cfg/app/Report.xml " & "PN=" & VarY & " " & "VN=" & VarX & " " & "SVC=" & VarZ

When I run the command I have the batch file echo back what it receives before running and the I get the followed echo backed to me

cmdfile=cfg/app/Report.xml PN= VN= SVC=
Mar 29 '07 #11
Rabbit
12,516 Recognized Expert Moderator MVP
I did that and I am still not seeing the VarX and VarY being passed into my command event. Do the VarX and VarY need to be public variables? I cannot understand why the value won't pass to the command line. There must be I am missing. Here are the steps I followed.

I opened the form is design view
I selected properties
I changed properties from Detail to Form
In the On Open event I placed the statements above with the correct "" added. See below

Private Sub Form_Open(Cancel As Integer)
Dim VarX
Dim VarY
Dim VarZ

VarX = DLookup("VNODE", "SSS_AOA_XML", "ID=1")
VarY = DLookup("PNODE", "SSS_AOA_XML", "ID=1")
VarZ = DLookup("SERVICE", "SSS_AOA_XML", "ID=1")

End Sub

I then went to the command button and added the variable to the statement contained in the OnClick event. See Below

stAppName = "c:\SubmitCommands.Bat " & "cmdfile=cfg/app/Report.xml " & "PN=" & VarY & " " & "VN=" & VarX & " " & "SVC=" & VarZ

When I run the command I have the batch file echo back what it receives before running and the I get the followed echo backed to me

cmdfile=cfg/app/Report.xml PN= VN= SVC=
As far as I can tell it should work assuming your fields are named id, vnode, pnode, and service. And that they're on the table named sss_aoa_xml. And that there is a record with id = 1 and the fields aren't empty.

If this is all true then it should work perfectly. Try setting a break point at the beginning of the code and step through the code (F8) step by step and see where it's going wrong.
Mar 29 '07 #12
sesling
84 New Member
As far as I can tell it should work assuming your fields are named id, vnode, pnode, and service. And that they're on the table named sss_aoa_xml. And that there is a record with id = 1 and the fields aren't empty.

If this is all true then it should work perfectly. Try setting a break point at the beginning of the code and step through the code (F8) step by step and see where it's going wrong.
I found the solution. I needed to remove the Dim VarX, Dim VarY etc from the On Open event and declare the variables outside any Private Sub step on the form. The variables were added below Option Compare Database

Dim VarX
Dim VarY
Dim VarZ

This worked for me. Thanks for your assistance
Mar 29 '07 #13
Rabbit
12,516 Recognized Expert Moderator MVP
I found the solution. I needed to remove the Dim VarX, Dim VarY etc from the On Open event and declare the variables outside any Private Sub step on the form. The variables were added below Option Compare Database

Dim VarX
Dim VarY
Dim VarZ

This worked for me. Thanks for your assistance
Sure, no problem. Although I don't understand why it wouldn't work within the sub. There's no reason for it not to.
Mar 30 '07 #14

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

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
3
by: Geoff Matthews | last post by:
I apologize for the basic question, but MS's documentation has been no help at all. I'm working on a database, and need to create a form for schedules, M-F, 8-4. I've settled on an easy way out,...
1
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary...
8
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I...
2
by: chfran | last post by:
I have a form that has data behind it. The user can manipulate the data behind the form through the form and see how it affects the statistics of the data. The users want to be able to reset or...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
2
by: Rob Richardson | last post by:
Greetings! I am struggling to understand data binding in VB.Net, and it's slow going. I have a list box bound to a dataset that is filled from a SQL Server table. In addition to the list...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
6
by: Brian Blair | last post by:
I have created a input form that enters a number in a talble. If I open the form again it enters a new record instead of editing the existing record. It seems like it should be very basic but I...
12
by: Richard Penfold | last post by:
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...
0
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,...
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,...
1
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...
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.