PDA

View Full Version : CurrentProject.Connection.Execute causing form to crash....



Movian
11-04-2014, 11:01 AM
I have a patch system built into my access DB and when a new copy of the front is downloaded it atempts to check / update tables.

The following section of a sub is setup to try and add fields / tables and on error fail (in this case an error would be the table / field exists).


However one of the following 3 executes causes the whole form to just close out without continuing.... it does the same thing if I use a docmd.runsql with warnings turned off

as always any help is appreciated.

~EDIT~
Temporary fix was to add on error resume next and on error goto 0 around the call to this sub procedure, adding them into the sub procedure itself did not help the problem.


'V6.9245


CurrentProject.Connection.Execute "ALTER TABLE Settings ADD SubjComplaints INT", dbFailOnError
CurrentProject.Connection.Execute "CREATE TABLE [tblReminderList]([ReminderID] [int] IDENTITY(1,1) NOT NULL,[MedicalID] [nvarchar](50) NULL,[ReminderDate] [date] NULL,[AppointmentType] [nvarchar](100) NULL,[DoctorToSee] [nvarchar](100) NULL, CONSTRAINT [PK_tblReminderList] PRIMARY KEY CLUSTERED ([ReminderID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]", dbFailOnError
CurrentProject.Connection.Execute "CREATE TABLE [tblChiefComplaintsSelections]([MedicalID] [int] NOT NULL,[LeftList] [nvarchar](max) NULL,[RightList] [nvarchar](max) NULL,[bilatlist] [nvarchar](max) NULL,[leftList2] [nvarchar](max) NULL,[rightList2] [nvarchar](max) NULL,[bilatList2] [nvarchar](max) NULL,[assoclist] [nvarchar](max) NULL,[assocText] [nvarchar](255) NULL, CONSTRAINT [PK_tblChiefComplaintsSelections] PRIMARY KEY CLUSTERED ([MedicalID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]", dbFailOnError

ranman256
11-05-2014, 01:46 PM
Is this trying to alter SQL tables, or ACCESS tables?
If access, dont use this method.
Use tabledefs("table") object to alter the table.

jonh
11-05-2014, 03:39 PM
Why?

++
not saying you are wrong. But what is the difference?