471,319 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Writing a little app to modify a file

Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following database
structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum SystemNumber
for a group, where a group is a unique System Key and System Name combo. The
SystemNumberMAX is only to be filled when there is more than 1 System Number
for a group. Thus, when the module is complete, the above file set should
look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting forms and
switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm
thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll ascii-delimit it
from Access first)
2. Select the max SystemNumber # for the group and write it to a variable.
3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max SystemNumber)
4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike
Nov 21 '05 #1
3 1060
Michael,

I made a sample for you that needs a datagrid,
I have made the table, however that you can read of course direct from your
access database.

\\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("Serial")
dt.Columns.Add("Name")
dt.Columns.Add("Key")
Dim dtresult As New DataTable
dtresult.Columns.Add("Serial")
dtresult.Columns.Add("SerialMax")
dtresult.Columns.Add("Name")
dtresult.Columns.Add("Key")
dt.LoadDataRow(New Object() {"9007404", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9007405", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9007406", "Windows Test 1", "A"},
True)
dt.LoadDataRow(New Object() {"9008683", "Windows Test 45", "A"},
True)
dt.LoadDataRow(New Object() {"9008684", "Windows Test 45", "A"},
True)
dt.LoadDataRow(New Object() {"9017616", "Windows Test 4595bg", "A"},
True)
dt.LoadDataRow(New Object() {"9019528", "Windows Test 1", "B"},
True)
Dim dv As DataView = dt.DefaultView
dv.Sort = "Name, Key"
Dim dr As DataRow
For Each drv As DataRowView In dv
If dr Is Nothing Then
dr = dtresult.NewRow
dr(0) = drv(0)
dr(1) = drv(0)
dr(2) = drv(1)
dr(3) = drv(2)

Else
If dr(2).ToString = drv(1).ToString And dr(3).ToString =
drv(2).ToString Then
dr(1) = drv(0)
Else
dtresult.Rows.Add(dr)
dr = dtresult.NewRow
dr(0) = drv(0)
dr(1) = drv(0)
dr(2) = drv(1)
dr(3) = drv(2)
End If
End If
Next
dtresult.Rows.Add(dr)
DataGrid1.DataSource = dtresult
End Sub
///

I did not really check it, however the result looks for me something what it
has to be.

I hope this helps,

Cor
Nov 21 '05 #2

One quick comment: If the data is already in Access, you should do this
with a query within Access rather than exporting and processing it. If
this is an acceptable solution just say if you want help with the query
:)

Michael D. wrote:
Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following database structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum SystemNumber for a group, where a group is a unique System Key and System Name combo. The SystemNumberMAX is only to be filled when there is more than 1 System Number for a group. Thus, when the module is complete, the above file set should look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45 A 9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting forms and switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll ascii-delimit it from Access first)
2. Select the max SystemNumber # for the group and write it to a variable. 3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max SystemNumber) 4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike


Nov 21 '05 #3
Yea, it IS already in Access... Actually, it is an Excel spreadsheet that I
put into access. However, I was thinking about writing a little VB app that
they could put on their desktop, click a button to select the file, and then
output a new/fixed file for them. The reason for that is they get the data
from an outside source on a montly basis, so it's not a 1-time thing... Does
that make sense? A query or VBA module would work either though, if I have
the query, I'm good enough (JUST!) to build the vb.net app, I think...

Thanks a lot!
Mike

"Larry Lard" wrote:

One quick comment: If the data is already in Access, you should do this
with a query within Access rather than exporting and processing it. If
this is an acceptable solution just say if you want help with the query
:)

Michael D. wrote:
Hello all!

I'm trying to design and write a little application for someone
in my office, but I'm having some trouble. I have the following

database
structure (Note: just some sample data, obviously):

SystemNumber SystemNumberMAX SystemName SystemKey
9007404 Windows Test 1 A
9007405 Windows Test 1 A
9007406 Windows Test 1 A
9008683 Windows Test 45 A
9008684 Windows Test 45 A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B

The SystemNumberMAX field is to be populated with the maximum

SystemNumber
for a group, where a group is a unique System Key and System Name

combo. The
SystemNumberMAX is only to be filled when there is more than 1 System

Number
for a group. Thus, when the module is complete, the above file set

should
look like this:
SystemNumber SystemNumberMAX SystemName SystemKey
9007404 9007406 Windows Test 1 A
9008683 9008684 Windows Test 45

A
9017616 Windows Test 4595bg A
9019528 Windows Test 1 B
I'm totally stumped though! I've only done stuff like affecting

forms and
switchboards in Access/VBA, and wrote a VB.NET tic-tac-toe game. I'm

thinking the steps are:

1. Read the file in, and split it by commas (meaning I'll

ascii-delimit it
from Access first)
2. Select the max SystemNumber # for the group and write it to a

variable.
3. Delete the records in the range between the minimum and maximum
SystemNumber for the group (including the record for the max

SystemNumber)
4. Write the max SystemNumber into the SystemNumberMAX field.

Can anyone offer guidance or example code for something similar?

Thanks! -Mike


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Fernando Perez | last post: by
6 posts views Thread by Sebastian Kemi | last post: by
5 posts views Thread by Benjamin de Waal | last post: by
2 posts views Thread by melanieab | last post: by
8 posts views Thread by Paul | last post: by
3 posts views Thread by Barry Flynn | last post: by
reply views Thread by =?Utf-8?B?QWxleA==?= | last post: by

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.