Nope.
OK, I cleaned up the code to keep necessary lines:
Public Function CreateExportTable() As Boolean
On Error Resume Next
Dim ws As Workspace
Dim db As DAO.Database
Dim strSQL As String
Dim table1 As String
Dim frm As String
Dim Form_Export As Form
Set ws = DBEngine.Workspaces(0)
Set db...
Looks like the way I did it doesn't work for random picked fields, so started to try your code.
Here is what I have just now, simply trying to run simple SELECT before I start creating tables and exporting it etc
I'm getting error saying: "Error updating: Object doesn't support this property...
taking off Set, gives me error Expected Array
EDIT:
OK, I got it working.
I did a separate function and called it later.
Function TableExists(strTableName As String) As Boolean
On Error Resume Next
TableExists = IsObject(CurrentDb.TableDefs(strTableName))
End Function
Then...
If...
I got this, but gives me error that Object required...
Dim strTableName As String
Dim TableExists As Boolean
Set TableExists = IsObject(CurrentDb.TableDefs(strTableName))
If TableExists("Data Export") = True Then
DoCmd.DeleteObject acTable, [Data Export]
End If
I wanted to run this but for some reason it doesn't work.
https://docs.microsoft.com/en-us/sql/t-sql/functions/identity-function-transact-sql?view=sql-server-ver15
But ok, I will run in steps, first create table with Autoincrement and other fields, then add data.
Another question: how can I...
Yes, first I want to create this new table from data from other table, but as well add first ID which would be autonumber.
I wanted to do it at one step.
Next would be export, but first I need this table created.
Of course I could run second sql line and alter table adding it, but I want it to...
But this Identity field is new, I'm adding it first, then take fields from other table. When I got rid of =, it didn't work.
Tried newID Identity(1,1),... or Identity(1,1) as newID.
Nothing worked.
Do I have to somehow declare this function first?
Thanks guys, it took me a while to use your suggestion, but its working great! :)
Thank you all!
I decided to create a table first with this data, then export it.
I have new problem, wanted to simply add autonumber first in this new table and for some reason when running SELECT newID =...
[SOLVED] SELECT INTO with Identity - getting error
I'm getting an error (Undefined function 'IDENTITY' in expression) when trying to run this line:
strSQL = "SELECT newID = IDENTITY(1, 1), Data.Company, Data.Title, Data.Fullname INTO [Data Export] FROM Data ORDER BY Data.ID"
Also tried...
I have a form with all table fields listed and check boxes next to them.
What I'm trying to achieve is to export all data fields that user selects to txt file.
Problem is it would need to check which check-box is picked, then export only these fields.
How can I do that in VB?
Could I write...
Yes, What I've done is I decided that minimum of 5 fields must be mapped.
Then built conditions for rest of them.
See, I'm not a developer, but I would love to know how to do it your way No.1 or No.2:)
Hello!:)
I've continued working on this db and came up on another problem.
It all works fine when I "map" exact number of fields.
My query in code had 23 fields as this is total amount of fields in "Data" table (processing one where data is inserted to).
However "Source" table (imported one)...
Holy S*** it worked!!!! :eek::D
Thank you thank you !!!!
You always answer all my questions in minutes, you sure you're not some kind of forum bot? :D
OK, now I'm gonna try to point second part of the puzzle - that form has another dropdowns with destinations fields (Data table) - so this way...
Sorry, I really appreciate your help.
Fixed it, gives me error: Compile error: Invalid use of Me keyword"
I've read some about "active" attribute.
How can we "point" to active form?
I believe "Me" was going to do that?
Something is missing there, all line goes red.
As far as I understand this code will simply pull data from ImportTable and add it to Data table.
Straight from it, not via form.
Reason for the form is that I want user to pick which fields he wants to insert, so it needs to come from form...
Sorry, you lost me...
Do what?
I know that my SQL string is wrong as this isn't a table, but form.
What I want it to do is to look at the form, get data fields names from dropdowns and get that data from ImportTable.
I added these:
Dim tbl2 As String
tbl2 = "ImportTable"
I fixed SQL to...