Solved

Visual Basic Arrays and Access Database

Posted on 2003-11-11
6
336 Views
Last Modified: 2013-11-25
I have a column in my access database table called "Lines", and I need it to be an array type somehow so that for each record in the table I can have multiple "Lines" and for each "Line" I can store an X1, Y1, X2, Y2.  Also, how would I use a select statement and update statement from visual basic to access and update that field?  I know I could just create a whole new table to do this for me, but would perfer not too.  I don't know a lot about access, use it rarely, so I'm sure is something beyond the basics I know to accomplish this.

Thanks, Jebus
0
Comment
Question by:dj__jebus
  • 3
6 Comments
 

Author Comment

by:dj__jebus
ID: 9726774
I just found the menu thing insert a subdatasheet.  Is this along the lines if something I could use?  How does it work and how would I implement it in my vb project to make it work?  Or is it completely unrelated?

Thanks Jebus
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9726907
How about adding them to the field seperated by a carraiage return:

' add a refence to Microsoft ActiveX Data Objects Library:

Dim DataBase As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
DataBase = "C:\MyDataBase"

' open Database Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DataBase & "'"
cn.CursorLocation = adUseClient
cn.Open

' open recordset
Set rs = New ADODB.Recordset
rs.Open "Select * From MyTable", cn, adOpenKeyset, adLockOptimistic

' add new record to Table
rs.AddNew
rs.Fields("Lines").Value = X1 & vbCr & X2 & vbCr & Y1 & vbCr & Y2
rs.Update

' update current record
rs.Fields("Lines").Value = X1 & vbCr & X2 & vbCr & Y1 & vbCr & Y2
rs.Update

' close recordset
rs.Close
Set rs = Nothing

' close connection
cn.Close
Set cn = Nothing


0
 

Author Comment

by:dj__jebus
ID: 9727271
I would like to try using this subdatasheet thing.  I have a table called "Jobs" in which I have a subdatasheet called "Walls"  In Walls I have my WallID, X1, Y1, X2, Y2 columns.  So all I need now is to write my sql string to be able to select and update things from the Walls table for each record in Jobs.

Thanks Jebus
0
 

Accepted Solution

by:
dj__jebus earned 0 total points
ID: 9744514
Well, I figured it out on my own.  I just made another table for Walls and used the relations thing in access.  I then used a normal select statement with a where JobID=blah  thing.

Thanks, Jebus
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Post a good COM tutorial 1 49
Hide vba in gp 7 82
Macro Excel - Multiple If conditions 2 63
how to know if my Checkbox is True in VB6.0? 9 38
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now