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

To create tables with VBA - To name the new table from a mask'txt box

I built the following Sub, in order to create tables automatically.
The button is placed on a mask where there are 3 txt box, two of them
contain the "Bank name" and "Bank a/c". I want to name the new table with a
string composed by the "Bank name"&"Bank a/c", How I could get it?
Using the following Sub I get always the same name "NEWBANKAC".

Any Tip is welcome.

Thank you.

Private Sub cmdADDNEWBANKAC_Click()
On Error GoTo TableErrCatcher
Dim cat1 As ADOX.Catalog
Dim tbl1 As ADOX.Table
Dim str1

'Reference objects for table
Set cat1 = New Catalog
cat1.ActiveConnection = CurrentProject.Connection
Set tbl1 = New Table
'Name table and append columns
With tbl1
.Name = "NEWBANKAC"
.Columns.Append "ID N", adInteger
.Columns.Append "DATE", adDate, 10
.Columns.Append "FIN CODE", adLongVarWChar, 4
.Columns.Append "DESCRIPTION", adVarWChar, 30
.Columns.Append "DEBIT", adDouble
.Columns.Append "CREDIT", adDouble

End With

'Append new table to Tables collection
'and free catalog resource
cat1.Tables.Append tbl1
Set cat1 = Nothing

str1 = NewBankac & "new bank account has been created"
MsgBox str1, vbInformation, "Cash Flow Management"

TableErrCatcher:
If Err.Number = -2147217857 Then
MsgBox "Bank account already existing", vbInformation, "Cash Flow
Management"
End If
Debug.Print Err.Number, Err.Description

End Sub
Nov 12 '05 #1
4 5352
rkc

"Amos" <am**********@hotmail.com> wrote in message
news:Oa**********************@twister1.libero.it.. .
I built the following Sub, in order to create tables automatically.
The button is placed on a mask where there are 3 txt box, two of them
contain the "Bank name" and "Bank a/c". I want to name the new table with a string composed by the "Bank name"&"Bank a/c", How I could get it?
Using the following Sub I get always the same name "NEWBANKAC".

Any Tip is welcome.


Re-think why you are creating a new table for each bank account instead
of adding a row to a BankAccounts table.

On to your question. You always get the same name because there is
nothing in 'your' code that ever changes the name.

This line: .Name = "NEWBANKAC"
Should be something like .Name = Me.txtBankName & Me.txtBankAcc

Nov 12 '05 #2
Thank you very much, now it works properly.
One thing more:
the table name is composed by a text box & combo box,
text box is the Bank a/c
combo box is the Currency (EU and USD)

Ex: text box = 123
combo box = EU

result is 1231, where 1 correspond to EU.

How I could get 123EU?

Thank you very much.
Amos



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
rkc

"Amos Marzuoli" <ri***********@yahoo.com> wrote in message
news:40*********************@news.frii.net...
Thank you very much, now it works properly.
One thing more:
the table name is composed by a text box & combo box,
text box is the Bank a/c
combo box is the Currency (EU and USD)

Ex: text box = 123
combo box = EU

result is 1231, where 1 correspond to EU.

How I could get 123EU?

Thank you very much.


Probably by going into the properties sheet of the combobox and
setting the bound column to the column that holds the text instead
of the column that holds the numeric key.



Nov 12 '05 #4
Amos Marzuoli <ri***********@yahoo.com> wrote in message news:<40*********************@news.frii.net>...
Thank you very much, now it works properly.
One thing more:
the table name is composed by a text box & combo box,
text box is the Bank a/c
combo box is the Currency (EU and USD)

Ex: text box = 123
combo box = EU

result is 1231, where 1 correspond to EU.

How I could get 123EU?

Thank you very much.
Amos

is there a reason you don't store the two as separate fields? Something like:

CurrencyType: (text)
Amount: 123
Nov 12 '05 #5

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

Similar topics

4
by: Amos | last post by:
I built the following Sub, in order to create tables automatically. The button is placed on a mask where there are 3 txt box, two of them contain the "Bank name" and "Bank a/c". I want to name the...
1
by: barry | last post by:
Hi there I create a table with the following code string strDLName = "Hello"; Response.Write("<Table id='ManageDlTable'>"); for(int i = 0; i < 6; i++)
6
by: David Thielen | last post by:
Hi; This works fine on my development system but fails on IIS on Win 2003. I have requests for filename.txt, filename.rtf, etc that must go to my ASP.NET code. I have the following in my...
4
by: Troels Arvin | last post by:
Hello, I've run into situations where a table was accidentally dropped. The related database contained lots of other tables in lots of other schemas used by many different users. So I couldn't...
3
by: jdblackford | last post by:
Hello, I was wondering if it was possible to create simple program that will create .txt (or .html) files based on information provided via prompts. For instance, if I wanted to create a file...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
1
by: remya1000 | last post by:
i need to create a .txt file and create this table inside that. Example: 6/13/2007 4:58:29 PM Day Part Count TimeinSec AVG...
2
daniel aristidou
by: daniel aristidou | last post by:
Hey... I've got a program...that organises customers... I want to create text files of each day........containing the IDs of customers seen........ However i want to organise the Text files in...
2
by: vjainpee | last post by:
Hi All, I m new to asp.net I want to make a notepad file through .net at run time ,put some text in the file and save the file at some location on the system and the file should be in open mode...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.