473,396 Members | 1,767 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,396 software developers and data experts.

Change Column definitions?

Hi

I have a vb app that uses an access database to store information. This app
has been distributed to several users. I would like to increase the size of
a field in an access table using my vb app so the users dont have to input
all their data again, what is the best way to do it. I normally use oracle
and would call something like an "alter table modfiy column col1
varchar2(100)". I'm guessing this cannot be done in access and a different
approach is needed.

Thanks for any help,

Tim

http://newtonsoftware.net
Nov 12 '05 #1
2 3557
"Tim Newton" <ti**@bigfoot.com> wrote in message
news:bm**********@sparta.btinternet.com...
Hi

I have a vb app that uses an access database to store information. This app has been distributed to several users. I would like to increase the size of a field in an access table using my vb app so the users dont have to input
all their data again, what is the best way to do it. I normally use oracle
and would call something like an "alter table modfiy column col1
varchar2(100)". I'm guessing this cannot be done in access and a different
approach is needed.

Thanks for any help,

Tim

http://newtonsoftware.net

Tim
If you are talking about Access 2000 onwards, ie version 4 of the Jet
database, then you can make use ALTER TABLE statement in the way you
suggest - well almost - change "varchar2(100)" to "TEXT(100)".
Here is a script which, although written in vb script, should show you the
idea.

HTH
Fletcher

' ************************************************** **********************
Const ROUTINE = "Update Routine"
Const DB_PATH = "C:\Test\"
Const STR_SQL = "ALTER TABLE MyTable ALTER COLUMN MyColumn TEXT(100)"
Call Main
Sub Main

Dim cnn
Dim strMsg
Dim strPath

strPath = GetPath()

If Len(strPath) = 0 Then
Msgbox "Update cancelled",vbInformation, ROUTINE
Exit Sub
End If

Set cnn = GetConnection(strPath)

If cnn Is Nothing Then
Msgbox "Unable to esatblish a Connection to database:" & vbCrLf & _
strPath & "'", vbCritical, ROUTINE
Exit Sub
End If

strMsg = TableError(cnn)

If Len(strMsg) = 0 Then
Msgbox "Table updated successfully", vbInformation, ROUTINE
Else
Msgbox "Error updating table:" & vbCrLf & strMsg, vbCritical, ROUTINE
End If

cnn.Close

Set cnn = Nothing

End Sub

Function GetPath()

On Error Resume Next

Dim objDlg
Dim str

str = ""

set objDlg = CreateObject("MSComDlg.CommonDialog")

If Err.Number = 0 Then
objDlg.Filter="Microsoft Access Databases (*..mdb)|*.mdb"
objDlg.DialogTitle = ROUTINE & " - Select the database..."
objDlg.InitDir = DB_PATH
objDlg.MaxFileSize = 260
objDlg.ShowOpen
objDlg.Flags = objDlg.Flags OR cdlOFNPathMustExist
objDlg.Flags = objDlg.Flags OR cdlOFNFileMustExist
objDlg.Flags = objDlg.Flags OR cdlOFNHideReadOnly
str = objDlg.FileName
End If

Set objDlg = nothing

GetPath = str

End Function
Function GetConnection(strPath)

On Error Resume Next

Dim cnn

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath

Set cnn = CreateObject("ADODB.Connection")

cnn.Open strCnn

If Err.Number = 0 Then
Set GetConnection = cnn
Else
Set GetConnection = Nothing
End If

End Function
Function TableError(cnn)

On Error Resume Next

Dim strErrMsg

strErrMsg = "Cannot Update Table"

cnn.Execute STR_SQL

If Err.Number = 0 Then

strErrMsg = ""

Else
strErrMsg = Err.Description

End If

TableError = strErrMsg

End Function

' ************************************************** **********************
Nov 12 '05 #2
thanks Fletcher, thats just what I wanted to know. Can you or anyone else
recommend a text book on JET v4 for access 2000.

Tim

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bm**********@sparta.btinternet.com...
"Tim Newton" <ti**@bigfoot.com> wrote in message
news:bm**********@sparta.btinternet.com...
Hi

I have a vb app that uses an access database to store information. This

app
has been distributed to several users. I would like to increase the size

of
a field in an access table using my vb app so the users dont have to input all their data again, what is the best way to do it. I normally use oracle and would call something like an "alter table modfiy column col1
varchar2(100)". I'm guessing this cannot be done in access and a different approach is needed.

Thanks for any help,

Tim

http://newtonsoftware.net

Tim
If you are talking about Access 2000 onwards, ie version 4 of the Jet
database, then you can make use ALTER TABLE statement in the way you
suggest - well almost - change "varchar2(100)" to "TEXT(100)".
Here is a script which, although written in vb script, should show you the
idea.

HTH
Fletcher

' ************************************************** **********************
Const ROUTINE = "Update Routine"
Const DB_PATH = "C:\Test\"
Const STR_SQL = "ALTER TABLE MyTable ALTER COLUMN MyColumn TEXT(100)"
Call Main
Sub Main

Dim cnn
Dim strMsg
Dim strPath

strPath = GetPath()

If Len(strPath) = 0 Then
Msgbox "Update cancelled",vbInformation, ROUTINE
Exit Sub
End If

Set cnn = GetConnection(strPath)

If cnn Is Nothing Then
Msgbox "Unable to esatblish a Connection to database:" & vbCrLf & _
strPath & "'", vbCritical, ROUTINE
Exit Sub
End If

strMsg = TableError(cnn)

If Len(strMsg) = 0 Then
Msgbox "Table updated successfully", vbInformation, ROUTINE
Else
Msgbox "Error updating table:" & vbCrLf & strMsg, vbCritical, ROUTINE
End If

cnn.Close

Set cnn = Nothing

End Sub

Function GetPath()

On Error Resume Next

Dim objDlg
Dim str

str = ""

set objDlg = CreateObject("MSComDlg.CommonDialog")

If Err.Number = 0 Then
objDlg.Filter="Microsoft Access Databases (*..mdb)|*.mdb"
objDlg.DialogTitle = ROUTINE & " - Select the database..."
objDlg.InitDir = DB_PATH
objDlg.MaxFileSize = 260
objDlg.ShowOpen
objDlg.Flags = objDlg.Flags OR cdlOFNPathMustExist
objDlg.Flags = objDlg.Flags OR cdlOFNFileMustExist
objDlg.Flags = objDlg.Flags OR cdlOFNHideReadOnly
str = objDlg.FileName
End If

Set objDlg = nothing

GetPath = str

End Function
Function GetConnection(strPath)

On Error Resume Next

Dim cnn

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath

Set cnn = CreateObject("ADODB.Connection")

cnn.Open strCnn

If Err.Number = 0 Then
Set GetConnection = cnn
Else
Set GetConnection = Nothing
End If

End Function
Function TableError(cnn)

On Error Resume Next

Dim strErrMsg

strErrMsg = "Cannot Update Table"

cnn.Execute STR_SQL

If Err.Number = 0 Then

strErrMsg = ""

Else
strErrMsg = Err.Description

End If

TableError = strErrMsg

End Function

' ************************************************** **********************

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Doug Baroter | last post by:
What is a good method/mechanism to swap the position of multiple columns? For instance, tblXZY has the followings columns and respective positions: tblXZY ====== xyzUUID 1 fn 2 ln 3...
5
by: Glenn Mulno | last post by:
Hi, I am trying to create a report page for several teams. Each team runs the same reports but the reports use different values. For a while this was getting insane everytime I updated the...
4
by: Dr John Stockton | last post by:
It looks as if the USA may be changing its Summer Time (DST) Rules, perhaps with immediate effect. Browsers use the rules selected in the OS, and I predict that in many cases the rules will not...
4
by: Isaac Dealey | last post by:
I've been searching for hours and hours and can't find what I need. I'm creating a scripted web application that's designed to manage multiple databases (MS SQL Server, MS Access, Oracle,...
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
4
by: jb | last post by:
I have discovered that when the WSDL is auto-generated in .NET (i.e. http://.../MyService.asmx?WSDL): * Prior to SP1, it generated xmlns:s0="http://mynamespace/" in <wsdl:definitions>, and then...
1
by: Justin Bezanson | last post by:
I have got the following report running as described in my other post http://forums.asp.net/thread/1320780.aspx I would like to know how to change the generic column headers (column1,2,3...) to...
11
by: td0g03 | last post by:
Hello, I just have a few questions. The first one be how would you print a pattern. I could use the if else, but I remember my teacher talking about something like for(i=1;i<=size;i) ...
5
by: _Who | last post by:
I spent all day yesterday trying different things. Something has happened so I can't change font size. I have a table and in the first cell I have only text. I tried using the cell's Style...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.