-
Oct 3rd, 2015, 12:33 AM
#1
Thread Starter
Enjoy the moment
[RESOLVED] Alter Table trying to insert as strings getting errors
i have 2 combobox and 1 Text Field
first combo is named CmbRecordsData where i load all the tables like this
Code:
Dim Rs As New ADODB.Recordset
Set Rs = CN.OpenSchema(adSchemaTables)
Do While Not Rs.EOF
CmbRecordsData.AddItem Rs!TABLE_NAME
Rs.MoveNext
Loop
Rs.Close
second combo is named CmbType where i add the type for the fields like this
Code:
CmbType.AddItem "Number"
CmbType.AddItem "Memo"
CmbType.AddItem "Currency"
CmbType.AddItem "Date/Time"
third is a text called TxtFieldName where i enter the field name to be stored
i am trying to alter a table which i choose from [CmbRecordsData]
pick the Type for the Column Name from [CmbType]
and insert the name of the field i want with[TxtFieldName ]
i converted the 3 of them to string so i can insert as my choice but whatever i try
i get all kind of errors
this is my code
Code:
Dim StrTabl As String
Dim StrFld As String
Dim StrSade As String
StrTabl = CmbRecordsData.Text
StrFld = TxtFieldName.Text
StrSade = CmbType.Text
StrSql = "Alter Table " & StrTabl & " Add Column " & StrFld & " & " & StrSade
CN.Execute StrSql
tnx for any help
salsa
-
Oct 3rd, 2015, 12:58 AM
#2
Thread Starter
Enjoy the moment
Re: Alter Table trying to insert as strings getting errors
i tried a diffrent approach still get errors but the debug print dosnt look like it has errors
Code:
Dim SQuery As String
SQuery = "ALTER TABLE " & _
CmbRecordsData.Text & _
" ADD COLUMN " & _
TxtFieldName.Text & " " & _
CmbType.Text
CN.Execute SQuery
debug print shows
Code:
?SQuery
ALTER TABLE Schedules ADD COLUMN TakePlace Date/Time
-
Oct 3rd, 2015, 09:16 AM
#3
Re: [RESOLVED] Alter Table trying to insert as strings getting errors
Is this Resolved? If not, I'll give you some advice.
-
Oct 3rd, 2015, 09:31 AM
#4
Thread Starter
Enjoy the moment
Re: [RESOLVED] Alter Table trying to insert as strings getting errors
-
Oct 3rd, 2015, 09:39 AM
#5
Fanatic Member
Re: Alter Table trying to insert as strings getting errors
Originally Posted by salsa31
i tried a diffrent approach still get errors but the debug print dosnt look like it has errors
debug print shows
Code:
?SQuery
ALTER TABLE Schedules ADD COLUMN TakePlace Date/Time
ALTER TABLE TableName ADD COLUMN ColumnName DateTime
Datatypes DATE, TIME, and DATETIME. These are for date, time, or a combination of date and time values.
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
Last edited by Tech99; Oct 3rd, 2015 at 09:45 AM.
-
Oct 3rd, 2015, 09:47 AM
#6
Thread Starter
Enjoy the moment
Re: [RESOLVED] Alter Table trying to insert as strings getting errors
tnx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|