473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3570
"Tim Newton" <ti**@bigfoot.c om> wrote in message
news:bm******** **@sparta.btint ernet.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(1 00)" 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",vbIn formation, ROUTINE
Exit Sub
End If

Set cnn = GetConnection(s trPath)

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("M SComDlg.CommonD ialog")

If Err.Number = 0 Then
objDlg.Filter=" Microsoft Access Databases (*..mdb)|*.mdb"
objDlg.DialogTi tle = ROUTINE & " - Select the database..."
objDlg.InitDir = DB_PATH
objDlg.MaxFileS ize = 260
objDlg.ShowOpen
objDlg.Flags = objDlg.Flags OR cdlOFNPathMustE xist
objDlg.Flags = objDlg.Flags OR cdlOFNFileMustE xist
objDlg.Flags = objDlg.Flags OR cdlOFNHideReadO nly
str = objDlg.FileName
End If

Set objDlg = nothing

GetPath = str

End Function
Function GetConnection(s trPath)

On Error Resume Next

Dim cnn

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

Set cnn = CreateObject("A DODB.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.co m> wrote in message
news:bm******** **@sparta.btint ernet.com...
"Tim Newton" <ti**@bigfoot.c om> wrote in message
news:bm******** **@sparta.btint ernet.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(1 00)" 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",vbIn formation, ROUTINE
Exit Sub
End If

Set cnn = GetConnection(s trPath)

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("M SComDlg.CommonD ialog")

If Err.Number = 0 Then
objDlg.Filter=" Microsoft Access Databases (*..mdb)|*.mdb"
objDlg.DialogTi tle = ROUTINE & " - Select the database..."
objDlg.InitDir = DB_PATH
objDlg.MaxFileS ize = 260
objDlg.ShowOpen
objDlg.Flags = objDlg.Flags OR cdlOFNPathMustE xist
objDlg.Flags = objDlg.Flags OR cdlOFNFileMustE xist
objDlg.Flags = objDlg.Flags OR cdlOFNHideReadO nly
str = objDlg.FileName
End If

Set objDlg = nothing

GetPath = str

End Function
Function GetConnection(s trPath)

On Error Resume Next

Dim cnn

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

Set cnn = CreateObject("A DODB.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
9573
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 phone 4
5
4779
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 queries I had to change them in many places. Then I started using server side includes to keep me from changing some items in multiple places. There is still some double (quadruple) updating going on though when I make
4
1938
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 have been updated. Since time servers send GMT/UTC, the actual civil time of the computer may be wrong; or, if the user corrects it manually the results of UTC functions may be wrong.
4
9697
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, PostgreSQL, MySQL) using the same interface. I need to figure out how to create a recordset that contains a list of all the column properties (column name, data type, character length) for a specified table. The MSysObjects table doesn't seem to contain...
6
10681
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 data on the datasource. It simply gets the first name and last name of an instructor and displays it in the grid. I have two major problems.... One, it doesn't display in the column until the row is saved, (Even after calling a refresh on the...
4
4605
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 output my web methods as "s0:MyWebMethod" in <wsdl:message> sections * At SP1, it generates xmlns:tns="http://mynamespace/" in <wsdl:definitions>, and then output my web methods as "tns:MyWebMethod" in <wsdl:message> sections
1
2211
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 meaningful names. I can change the DataSet column definitions like this ds.Tables.Columns.ColumnName = "Contact Name"; But it causes and error when binding to the report.
11
2639
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) printf($); Code below will take the size of what I input and change the size of the pattern by adding more or less $
5
3068
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 to change the font size. I tried using the cell's attribute to change the font size. I tried adding a paragraph element and doing the above to it. Removed all font sizes from Body, Table...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8995
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3677
muto222
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.