473,406 Members | 2,847 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,406 software developers and data experts.

Creating a Program Loop in VB

Hello,

I am trying to create a loop in an MS Access application that will read in a list of iSeries system names from a file in my Access database, and then submit a command to each of the listed systems.

I have the code working for submitting the commands to one iSeries system at a time, the problem I am encountering is when I try to us a loop to submit the command to a list of systems.

Here is what I have for the command loop, my problem that I have hit, which is probably very rudamentary, is that I can't seem to specify a file within my database correctly.

I keep receiving an error stating "Run-time error '53': File not found

The file definitley exist, and the spelling is correct. Is there some syntax I am missing to specifiy the file in my current database?

*note - iseries is the name of the field which I am trying to read in.

Expand|Select|Wrap|Line Numbers
  1.  
  2. If system_name = "ALL" Then
  3.  
  4.     Open "myfile" For Input As #1
  5.         Do While Not EOF(1)
  6.         system_name = iseries
  7.         YOUR400.Define system_name
  8.  
  9.         Set Command.system = YOUR400
  10.  
  11.         ' Enter USERID and PWD so the users will not be prompted
  12.         Command.system.USERID = USERID
  13.         Command.system.Password = Password
  14.  
  15.         CU = command_run
  16.  
  17.         Command.Run CU
  18.         Loop
  19.     Close #1
  20.  
  21.     MsgBox ("Command '" & command_run & "' has been issued to all systems by '" & USERID & "' ")
  22.  
  23. End If
  24.  
  25.  
Any help is greatly appreciated, and I apologize if this question is very elementary in nature.

Thank you.
May 16 '08 #1
10 2614
NeoPa
32,556 Expert Mod 16PB
I'm not really getting the question I'm afraid.

With something like this it's important that you get all your details correct. My understanding starts to go grey and fuzzy in the first paragraph as Access databases don't contain files :S
I am trying to create a loop in an MS Access application that will read in a list of iSeries system names from a file in my Access database, and then submit a command to each of the listed systems.
There are other parts too which don't quite make sense so I couldn't get back on track.

If you have code which does work (for a single item say) then post that explaining what it does.

If you then go on to say where it goes wrong with your attempted loop then it may help someone to help you.
May 16 '08 #2
I'm not really getting the question I'm afraid.

With something like this it's important that you get all your details correct. My understanding starts to go grey and fuzzy in the first paragraph as Access databases don't contain files :S

There are other parts too which don't quite make sense so I couldn't get back on track.

If you have code which does work (for a single item say) then post that explaining what it does.

If you then go on to say where it goes wrong with your attempted loop then it may help someone to help you.
Sorry for the confusion, I should have said there is a table in my database that I am trying to read in.

Here is the code that I am using to send a command to a single iSeries server, this code currently works:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command10_Click()
  2.  
  3. Dim systemNames As New cwbx.systemNames
  4. Dim YOUR400 As New cwbx.AS400System
  5. Dim Command As New cwbx.Command
  6. Dim CU As String
  7.  
  8.  
  9.  
  10. YOUR400.Define system_name
  11.  
  12. Set Command.system = YOUR400
  13.  
  14. ' Enter USERID and PWD so the users will not be prompted
  15. Command.system.USERID = USERID
  16. Command.system.Password = Password
  17.  
  18. CU = command_run
  19.  
  20. Command.Run CU
  21.  
  22. MsgBox ("Command '" & command_run & "' has been issued to '" & system_name & "' by '" & USERID & "' ")
  23.  
  24. End Sub
  25.  
The variables are being passed from user input entered on a form, and the process is enacted by clicking a command button.

What I am trying to do is to be able to submit a single command to multiple iSeries servers by reading the list of server names in from a table located in my Access database.

Here is the code I have so far (assuming "myfile" is my table listing the iSeries machines in a column called "iseries":

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command10_Click()
  2.  
  3.  
  4. Dim systemNames As New cwbx.systemNames
  5. Dim YOUR400 As New cwbx.AS400System
  6. Dim Command As New cwbx.Command
  7. Dim CU As String
  8.  
  9. Open "myfile" For Input As #1
  10.         Do While Not EOF(1)
  11.         system_name = iseries
  12.         YOUR400.Define system_name
  13.  
  14.         Set Command.system = YOUR400
  15.  
  16.         ' Enter USERID and PWD so the users will not be prompted
  17.         Command.system.USERID = USERID
  18.         Command.system.Password = Password
  19.  
  20.         CU = command_run
  21.  
  22.         Command.Run CU
  23.         Loop
  24. Close #1
  25.  
  26. MsgBox ("Command '" & command_run & "' has been issued to all systems by '" & USERID & "' ")
  27.  
  28. End Sub
  29.  
Sorry if I am leaving anything out I apologize, I am really new to VB.

Thanks again for all of your insight.
May 16 '08 #3
Sorry, one more piece of information:

The form that is submitting the VB script has four fields:

userid (text box)
Password (text box)
system_name (combo box derived from a table (system_options.iseries)
command_run

The entire code uses two If...then statements to determine whether or not the user is trying to submit a command to a single iSeries (AS400) system or all of our iSeries systems (in which case the user would choose ALL instead of a specific system name.)

I removed the If. . .then statements for the sake of separating the code into what works, and what doesn't.

Hope this helps . . . thanks again.
May 16 '08 #4
NeoPa
32,556 Expert Mod 16PB
That's really quite well explained now Cricket.

I will have a look at this over the weekend and see if I can't determine the problem.
May 16 '08 #5
That's really quite well explained now Cricket.

I will have a look at this over the weekend and see if I can't determine the problem.

I really appreciate the help, I have been racking my brain and scouring the internet, but all of the examples reference files outside of databases.

On a side note, this site has been a valuable resource while I have been coding for various projects. There is a ton of good info archived here. Thanks to all who contribute, your efforts are helping a lot of people.
May 16 '08 #6
NeoPa
32,556 Expert Mod 16PB
Nice of you to say so. We're trying to build up a useful archive so that it can be used not only as an interactive forum, but also a repository of knowledge for anyone to search through :)
May 16 '08 #7
NeoPa
32,556 Expert Mod 16PB
I didn't manage to get on at all over the weekend so I will fit in a look at this as soon as I can.
May 19 '08 #8
NeoPa
32,556 Expert Mod 16PB
I've had a deeper look now and I'm coming unstuck on your reference to a cwbx object. This is unclear and unreferenced as far as I can see. What and where is the code that defines or declares it?
May 19 '08 #9
I've had a deeper look now and I'm coming unstuck on your reference to a cwbx object. This is unclear and unreferenced as far as I can see. What and where is the code that defines or declares it?
I am a little embarrassed to admit I do not know. Most of my coding in VB has been done the "banging my head into walls" method, so some of structure etc. is a bit hazy to me.

I do know that when I have seen connections made to an AS/400 those Dim statements seem to be declared most of the time. I am not sure why they are referred to as cwbx though.

I am going to do some more reading, and will report back with anything further I find.

Thanks again for all of your help.
May 19 '08 #10
NeoPa
32,556 Expert Mod 16PB
I expect it's declared somewhere in your code if not defined (Declaration is where a reference is made to a pre-existing entity (external library or such like) whereas a definition is where it's created within your code).
May 19 '08 #11

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

Similar topics

2
by: David | last post by:
Is it possible to create a loop in PHP, embedded in a web page, that periodically queries another program (like a web service for example), and correspondingly updates the information on the web...
26
by: Protoman | last post by:
How would you use a lookup table of char*, I mean, how would you find out where the intersection of D and E is? And how would you read two strings, and parse each character. Here's the array: ...
6
by: F-13 | last post by:
I'm working on a BOM in Access 200 from an example downloaded from from the web. The sample database contains three tables, Assemblies (the list of items needed to assemble any assembly),...
0
by: /2ez|n | last post by:
I found the answer, but thanks for all the help! For my c++ class I have to make a small win32 console program that calculates body mass index. The user will enter in a their first and...
3
by: Erik Foreman | last post by:
I am using a folderbrowserdialog object to prowse to a folder then once in that folder I am going to have my program rename all of the files in that folder. I know the rename funchtion but I am not...
1
by: nabman | last post by:
OK, I am creating a program where I have two forms, the login and main form. On the login form the user will be prompted to enter their account number and password. This info is read from a file....
41
by: c | last post by:
Hi every one, Me and my Cousin were talking about C and C#, I love C and he loves C#..and were talking C is ...blah blah...C# is Blah Blah ...etc and then we decided to write a program that...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
20
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to...
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...
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...
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
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
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...
0
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,...

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.