Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Inserting A Table In A RichTextBox


I would like to use a RichTextBox, from VB, to make my report. My question is if I want to put my data in a table with 3 columns and insert the new data into a new row, how can I do that? How can I introduce in a RichTextBox a table? I could not find any example about this!

Thanks in advance

My very best regards,

Celso




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Inserting Images In A Richtextbox, How?
How can I insert an image in a richtextbox?

Thanx in advance.

Inserting Multiple Table (with Joins) To A Table
Helllo everyone,


I have 5 tables in an *.mdb(I am using MS Access).
Namely:
1: Arbal
2: Address
3: Details
4: MRU
5: DMZ

Usually we see these tables connect by the result of the query.

How do I insert these tables into 1 table only.

Thanks

Inserting Image Into RichTextBox's Control
Is it possible to insert image into some kind of static form(control) in RichTextBox?

I know 2 way to insert image like following
1)
Clipboard.Clear
Clipboard.SetData LoadPicture(img)
SendMessage rtb.hWnd, WM_PASTE, 0, 0
Clipboard.Clear
2)
rtb.OLEObjects.Add , , img

But, upper 2 way has a limit.
In case of insert image, image is too bic because it is not inserted into some control(for example PictureBox)
What I want is to make picture box (or other control) into RTF first, and load image into it.
Is it possible?
Could anybody who know it let me know?

Richtextbox Inserting Extra Carriage Returns
I've been noticing that the Richtextbox inserts an extra carriage return when working with a block of text over a page long. What brought this to my attention is that I have a small text editor that has to edit files that occasionally are two or three pages long and I'm finding that if a record is like the following:

line 1
line2
line3
line4

eventually, when saving, the Richtextbox inserts
chr(13)chr(13)chr(10).

The double character 13s occur approximately at a page break. I'm wondering if anyone knows how to turn this off or knows how to work around it. Simply searching and replacing the offending characters is not an option. While it works for small files, many of the process files are 70-100 MB (which takes approximately a minute to save using the Editor), and from my tests, VB isn't very suited to moving and replacing such large strings.

Thanks

Inserting Image Into RichTextBox's Static Control
Is it possible to insert image into some kind of static form(control) in RichTextBox?

I know 2 way to insert image like following
1)
Clipboard.Clear
Clipboard.SetData LoadPicture(img)
SendMessage rtb.hWnd, WM_PASTE, 0, 0
Clipboard.Clear
2)
rtb.OLEObjects.Add , , img

But, upper 2 way has a limit.
In case of insert image, image is too bic because it is not inserted into some control(for example PictureBox)
What I want is to make picture box (or other control) into RTF first, and load image into it.
Is it possible?
Could anybody who know it let me know?

RichTextBox, Unicode And Inserting Characters Viar TextRTF
Hello,

I have little knowledge of RTF, but I guess it is possible to insert (as well as retrieve) unicode characters to (and from) a RTF file.

The RichTextBox control has the TextRTF property, if I'm not mistaken. What code do I have to use to insert an arbitrary character (on the cursor position, for instance)?

If I know the hexadecimal (or decimal) value of the character, e.g. Arial Unicode MS [ʧ] (post-alveolar affricate in the IPA, the initial consonant in words like "check", "cheese" or "choose", word-finally "catch" etc.) has the HEX value &H2A7 (DEC 679).

It means, probably, that I will have to make a function that will convert the (hexa)decimal value to its RTF representation and manipulate the TextRTF property somehow. Let's say, the function would look as follows:

Public Function Char2RTF(UnicodeText as String) as String

By the way, how can I paste the character to a specific position in the box? (right after the cursor, for example)

Thanks for any help or advice in advance - the more specific, the more grateful I will be ;-)

Best wishes,

Petusek

Visible Property Of RichTextBox Control Is Changed To True On Inserting Bitmap
Hi everybody,
Before displaying data on a RichTextBox control, I am setting its Visible property to False, populating the control and then setting its Visible property to True. My problem is that on inserting a bitmap in the control, the Visible property is automatically set to true and the control is displayed before I set the Visible property to True. Can this problem be overcome ?

Inserting Table.....
hiiii
i am doing project on making text edietor in world doc style in visual basic..and i want to insert one tab (insert table) in that text editor as in microsoft world...but i couldn't find it anywhere..

so kindly help me regarding this... as soon as possible...
because it is very very important for me to do....

Ravi Handa

INserting A New Table At A Bookmark
I need to insert a table at a bookmark any ideas please

Inserting Text I Table??
How can i insert text from a texbox into a table in a Word document?

I don't want to use bookmarks...

Inserting Table Into Word
I have the following code (referenced to Word9.olb

It works FINE for the first time, but
any time after that, it bombs out on the code where "set mytable blahblahblah"
with an "add object failed" error.
Word is then left hanging in the processes...

I'd really like to get this sorted and any help would be most appreciated.


Dim WithEvents mobjword As Word.Application



Private Sub Command1_Click()
'On Error GoTo er1
Screen.MousePointer = 11

Set mobjword = Nothing
Set mobjword = New Word.Application
mobjword.Visible = True

Set newdoc = mobjword.Documents.Add

mobjword.Selection.Font.Name = "Verdana"
mobjword.Selection.Font.Size = "8"


mobjword.ActiveDocument.PageSetup.Orientation = wdOrientLandscape

With newdoc.Sections(1).Footers(wdHeaderFooterPrimary)
.PageNumbers.Add PageNumberAlignment:=wdAlignPageNumberCenter
End With

Set mytable = newdoc.Tables.Add(Selection.Range, 10, 10)

mytable.Columns.AutoFit


End With
DoEvents
'mobjword.Visible = True
DoEvents
Set newdoc = Nothing
Set mytable = Nothing
DoEvents
Set mobjword = Nothing
End Sub

Inserting Recordsets From Another Table
How can you insert a recordset to another table (table1) from a different network drive to table2, where table2 is not accessable by some users? Will "INSERT", or Replicate work?

Basically I have two tables one is on the shared drive, which is accessable by all users. And the other one is in drive I: where only certain people can access it.

Need Help With Inserting Data Into Sql Table
I have a form containing textboxes of txtID, txtSYSNAME, txtSYSTYPE, txtFREQ, txtPOP and a [Save] button to insert the data into an sql table.
The form also have a sqlconnection1, sqldataadapter1, and a generated dataset named WV2. The problem I'm having is that the following code does not perform an insert operation and it does not generate any errors. I'm new to vb.net, so any help is appreciated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p_idn, p_fq, p_pop As Int32
Dim p_name, p_type As String

p_idn = txtID.Text
p_name = "'" & Trim(txtSYSNAME.Text) & "'"
p_type = "'" & Trim(txtSYSTYPE.Text) & "'"
p_fq = Convert.ToInt32(txtFREQ.Text)
p_pop = Convert.ToInt32(txtPOP.Text)

SqlDataAdapter1.InsertCommand.CommandText = "INSERT INTO test (idnumber,sysname,systype,bacfreq,population) VALUES values (p_idn, p_name, p_type, p_fq, p_pop)"
SqlDataAdapter1.Update(WV21)

End Sub

Inserting Records Into SQL Table
I wrote a vbscript that writes the output to a file. I woudl like it to instead insert the records to a SQL Server table. What am I doing wrong from the code below:

Dim cn As New ADODB.Connection
Dim connString As String
Dim rs As New ADODB.Recordset
Dim sql As String

connString = "Provider=SQLOLEDB;Data Source=master;Initial Catalog=Test;User Id=User;Password=yes;"

cn.Open connString
rs.ActiveConnection = cn
rs.Source = "wrk_test"
rs.Open, cn

For Arrayloop = 0 To ArrayCount - 1
sql = "INSERT INTO wrk_test (col1, col2) VALUES " & 1
"," & 2 & " "

rs.Open sql, connString,,,adCmdText
Next
rs.Close
cn.Close


TIA.

SQL For Inserting Values From One Table To Another
Using Oracle, I have 2 tables:

USERS with columns: USERID, PASSWORD, PSWDCLUE, URL, GENDER, FNAME, MNAME, LNAME, TELNO, CELNO, ADDRESS, EMAIL, BIRTHDAY, NICKNAME, STATUS

DELETEDACCOUNTS with columns: USERID, PASSWORD, PSWDCLUE, URL, GENDER, FNAME, MNAME, LNAME, TELNO, CELNO, ADDRESS, EMAIL, BIRTHDAY, NICKNAME, STATUS

I'm trying to delete records from USERS then transfer them to DELETEDACCOUNTS. I think there's something wrong with my SQL...


Code:
Dim objDB As New ADODB.Connection
Dim objDB3 As New ADODB.Connection
Dim strConnectionString As String
Dim strConnectionString3 As String
Dim strSQL As String
Dim strSQL3 As String

Dim strID As String

strConnectionString = "Driver={Oracle in OraHome92};ConnectString=mylsi;UID=scott;PWD=tiger;"
objDB.Open strConnectionString

If Accounts.lvwAccounts.SelectedItem.Selected = True Then
If MsgBox("Are you sure you want to delete the selected record?", vbYesNo) = vbYes Then

strID = Accounts.lvwAccounts.SelectedItem.Text

strSQL = "DELETE FROM USERS WHERE USERID = '" & strID & "' "
objDB.Execute strSQL

strConnectionString3 = "Driver={Oracle in OraHome92};ConnectString=mylsi;UID=scott;PWD=tiger;"
objDB3.Open strConnectionString3

strSQL3 = "INSERT INTO DELETEDACCOUNTS (USERID, PASSWORD, PSWDCLUE, URL, GENDER, FNAME, MNAME, LNAME, TELNO, CELNO, ADDRESS, EMAIL, BIRTHDAY, NICKNAME, STATUS) FROM SELECT USERID, PASSWORD, PSWDCLUE, URL, GENDER, FNAME, MNAME, LNAME, TELNO, CELNO, ADDRESS, EMAIL, BIRTHDAY, NICKNAME, STATUS FROM USERS WHERE USERID = '" & strID & "' "
objDB3.Execute strSQL3

Accounts.lvwAccounts.ListItems.Remove (Accounts.lvwAccounts.SelectedItem.Index)
End If
End If

Inserting Data Into Table
im trying to add to a table, what is stored in an array, i thought id do as follows:

rs!ID = txtID.Text
rs!FName = array.Value(0)
rs!MName = Myarray.Value(1)
rs!LName = Myarray.Value(2)

but cuming up wiv error "Argument not optional" for ".Value"

any ideas???????

Inserting Table To Another Mdb With Password
How can I copy table from another mdb with password.

I have tried using this the code below and its working if the destination table is not password protected.


Code:
strSQL = "SELECT * INTO" & Space(1) & "[" & Destination & "]" _
& "." & NewTable & Space(1) & "FROM" & Space(1) _
& "[" & Source & "]" & "." & NewTable
cnnSource.Execute (strSQL)


pls. advice

Inserting Table Into Word Doc
I amusing the following code to make a table to be put into a Word Document:

ObjWord.ActiveDocument.Range(1).FormattedText.Bold = True

sLine = vbCrLf & "Age" & vbTab & "Year" & vbTab & "Premium" & vbTab & "Cash Value" & vbTab & "Death Benefit" & vbCrLf

ObjWord.ActiveDocument.Range(1).InsertAfter sLine


Do While Not rsCV.EOF
ObjWord.ActiveDocument.Range(1).FormattedText.Bold = False
sLine = rsCV("Age") & vbTab & rsCV("Year") & vbTab & rsCV("CP") & vbTab & rsCV("CSV") & vbTab & rsCV("DB") & vbCrLf
ObjWord.ActiveDocument.Range(1).InsertAfter sLine

rsCV.Delete adAffectCurrent
rsCV.MoveNext
Loop

ActiveDocument.Range(1) .ConvertToTable
ActiveDocument.Range(1).Borders.OutsideLineStyle = wdLineStyleDouble
ActiveDocument.Range(1).Borders.InsideLineStyle = wdLineStyleNone

End With


This will make a nice table , but the problem is that I need to insert it into a column in Word Document. I am hacking away at this, not really knowing what I am doing. Is there an easy solution I just cannot see.

Thanks

Inserting Into Table Out Of RecordSet
Hi all,

Our system has two databases. One that recieves live data and another one we transferred older data too. This allows the first database to run continually and keeping recordCount to a minimum.

Im developing a User Interface, where the user selects two databases and two connections are opened. Then they select tables they want to copy out and table they want to export the data to.

I fill a recordset with all the data from table 1, but dont know column names, or number of columns for destination table. How do I insert the data from table1????

Can you write an Insert without specifying Column Names?
Can you do an Insert with a nested SELECT??
Any ideas at all are as always gratefully recieved. Thank You.

Inserting A Record Into A Table
My problem is i am only getting the first character into the first field. So if a try to insert "12345" only "1" is put into the field. The field is called "Fixture".

here is my code:

Set InsComm = New ADODB.Command
     Set InsConn = New ADODB.Connection
     Text100 = Mid(CompareText, 1, 100)
     InsSql = "INSERT INTO InventoryDescriptions ( Fixture, Price, Lamp, Ballast, Retrokit, LaborCost ) VALUES (Text100, 0, 0, 0, 0, 0);"
     InsConn.Open NesConnString
     Set InsComm.ActiveConnection = InsConn
     InsComm.CommandText = InsSql
             
     On Error GoTo TheError
     InsComm.Execute InsSql, adCmdText
     
     GoTo TheClose
 
TheError:
     
      msg = "ERROR # " & Str(Err.Number) & "Was Generated by " _
           & Err.Source & Chr(13) & Err.Description
     MsgBox msg, , "Error", Err.HelpFile, Err.HelpContext
     Exit Sub
     
TheClose:
     
     InsConn.Close
     
 End Sub

thanks, bob

Problem With Inserting Into Table
HI guys,

Thanks already for any help. I am new to VB and here is my question:

I am trying to insert into a table, but I keep getting this error: (Using Firebird 1.0)" ODBC:

Dynamic SQL Error
SQL Error COde = -104
Token Unknown - Line 1, Char 28
[

-------------------------
This is my code and the offending line:

Code:

Dim MesaConn As New ADODB.Connection
Dim AbrirMesa As New ADODB.Command
Dim strgSQL1 As String, strgConn As String

MesaConn.ConnectionString = "DRIVER=Firebird/InterBase(r)driver;UID=SYSDBA;PWD=tudiro;DBNAME=C:DATACOOKDATACOOK.GDB"
MesaConn.Open
strgSQL1 = "INSERT INTO MESAS_ABERTAS ([NUMERO], [STATUS])VALUES ('" & txtTableNumber.Text & "', '" & A & "')"


AbrirMesa.CommandText = strgSQL1
AbrirMesa.CommandType = adCmdText
AbrirMesa.ActiveConnection = MesaConn
AbrirMesa.Execute <-----


txtTableNumber is coming from the form and A is just a default value to enter into the field. I have changed it to get a value from another textbox instead of entering like I did, and I get the same error on either situation.
Can anybody help? I am scrathing my hair off with this!!!!

Thanks again, HErick

Inserting A Recordset Into A Table
How can I insert a recordset into a table (new or existing) using SQL in VB access 2000

I have tried this but I get told "Two few parameters"

strSQL = "INSERT INTO [test] (Code:, [descript]) SELECT rstTemp![code] , rstTemp![descript] "

CurrentDb.Execute strSQL

Inserting Image Into A Table
is it possible to save a picture into a field in an oracle table.
If so how?I want to know which datatype i have to selcet. Is BLOB ok for this purpose.

Inserting Records Into Tables From Another Table
Hi All,

I was just trying to find some code examples of how to import data from one table into multiple other tables which have been normalized. Which will add new values if it was new data and to overwrite the data if that primary key already exsisted. I am trying to code this in MS Access in VBA. Oh and another question is I am unable to get a variable named:
Dim db As Database in MS Access VBA anyone know if this is possible?


Thanks,
Swartz

Prob In Inserting Data Into Table
Hi, i got a prob in inserting data into tbl, can anyone help me 2 debug my error?

mSQl = "SELECT FMNHDB_CALL_ASSIGNMENT.CALL_KEY, FMNHDB_CALL_ASSIGNMENT.DISTRICT, FMNHDB_CALL_ASSIGNMENT.RECEIVED_DATE, FMNHDB_CALL_ASSIGNMENT.COMPANY_NAME, FMNHDB_CALL_DETAIL1.CALLER_NAME, FMNHDB_CALL_DETAIL1.CALLER_PHONE, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_1, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_2, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_3, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_4, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_5, FMNHDB_CALL_DETAIL2.PRODUCT_LINE, FMNHDB_CALL_ASSIGNMENT.ENG_REPAIR_TYPE FROM (FMNHDB_CALL_ASSIGNMENT INNER JOIN FMNHDB_CALL_DETAIL1 ON (FMNHDB_CALL_ASSIGNMENT.CALL_KEY = FMNHDB_CALL_DETAIL1.CALL_KEY) AND (FMNHDB_CALL_ASSIGNMENT.RECEIVED_DATE = FMNHDB_CALL_DETAIL1.RECEIVED_DATE)) INNER JOIN FMNHDB_CALL_DETAIL2 ON FMNHDB_CALL_ASSIGNMENT.CALL_KEY = FMNHDB_CALL_DETAIL2.CALL_KEY WHERE FMNHDB_CALL_ASSIGNMENT.ENG_A_OR_B_FLAG='A' and ("

DoCmd.RunSQL ("Insert Into Tbl_DataNeeded " & mSQl)"

Inserting A Column In A Table At Specified Location
I use ADOX in my VB 6 program for adding any new column to a table (MSAccess format). The following piece of code normally does that. My problem is to insert any new column at a particular position. For example I want to have my new field to be as the 3rd column-thereby pushing all existing columns from 3 downwards (1 2 newfield 4 5 6..), where 4,5,6 etc were earlier in positions 3,4,5.. Please help me on how to do this

My code goes here as a moduel level procedure

Code:
Public Sub InsertColumn(DbName As String, TableName As String, ColName As String, ColType As String, _
ColNullable As Boolean, ColWidth as Integer, Optional ColPosition As Integer = 0)

Dim conn As ADODB.Connection
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim Col As ADOX.Column

On Error GoTo AddFieldError
Set conn = New ADODB.Connection
' Open the connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DbName & ";" & _
"Persist Security Info=False"

conn.Open

' Make a catalog for the database.
Set cat = New ADOX.Catalog
Set cat.ActiveConnection = conn

' Get the table and insert the field (column)
Set tbl = cat.Tables(TableName)
' Create the field
Set Col = New ADOX.Column
Col.Name = ColName
If ColNullable Then
Col.Attributes = adColNullable
Else
Col.Attributes = adColFixed
End If

Select Case ColType
Case "Text"
Col.Type = adVarWChar
Col.DefinedSize = ColWidth
Case "Boolean"
Col.Type = adBoolean
Case "Date" 'Date field
Col.Type = adDate
...other data types
End Select

' Add the field.
If ColPos Then
'*************************************
'here I want to insert the column at the specific location specified by the argument 'ColPos' , say ColPos = 3
'how to do this?
'*************************************

Else
'if column position is not specified then simply add the column at the end
tbl.Columns.Append Col
End If
conn.Close

Exit Sub

AddFieldError:
conn.Close
MsgBox "Error " & Err.Number & _
" in creating the field '" & ColName & "' " & vbCrLf & _
Err.Description
Exit Sub

Set conn = Nothing

End Sub

Edit by Moderator: Please use the [vb][/vb] tags when you post code. Edit or reply to the post to see how.

Thank you.

SQL Query For Inserting Percentages To Table
Hi,

This is my first post on this forum. Thanks for taking the time to read this post and answer my question. It is very much appreciated. Hopefully, I will be able to return the favor someday.

I have a project where I am using an access database and ado.

The purpose it to collect data from the user, add it to the tables in the database and generate reports and charts based on the data.

My problem right now is with the reports. I need to calculate percentages for various reports based on the columns of data in the db.

Here is the sql code I am using to calculate the percentage for a report that wants to know the percentage of people that have the same satelite/cable providers.


Code:
'table CableProvider
Conn1.Execute " Delete from CableProvider"
Conn1.Execute "Select SatCableProvide From Info"
Conn1.Execute "Insert Into CableProvider(Provider,TotalSurveys,Percentage) Select SatCableProvide, count(*),count(*)/(SELECT COUNT(*) FROM Info) FROM Info GROUP BY SatCableProvide"
I have many reports to make that will use this type of query. My problem is with other reports that want multiple percentage values. For instance, I have a table called Newspaper.
In the table are the columns:
Newspaper - Total - TotalPercent - Day - PercentDay

I need to create a query that will calculate the percentage for the totalPercent column and the PercentDay column group by Newspaper1, Newspaper1d1.

Newspaper1 is the first pick, or most popular newspaper and newspaperd1d1 is the most read day for the most popular newspaper.

I would sincerely appreciate if anyone can take a stab at the query that will generate this information....

Thank you.

Inserting Records In To SQL Table With Quotes
i have a variable that contains data with quotes and its hosing my SQL insert statements. how do you work around this?

here is what i have so far:

Dim statement As String
Dim conn As ADODB.Connection

' db_file is the Access database's file name.
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Driver={SQL _ Server};Server=THEMACKDADDY;Database=SearchEngine;Trusted_Connection=y es;"
conn.Open

' Compose the INSERT statement.
statement = "INSERT INTO Addresses " & _
"(StoryData, PubDate, ID, Email, Content) " & _
" VALUES (" & _
"'" & StoryData & "', " & _
"'" & PubDate & "', " & _
"'" & ID & "', " & _
"'" & Email & "', " & _
"'" & Content & "'" & _
")"


' Execute the statement.
conn.Execute statement, , adCmdText

' Close the connection.
conn.Close


StoryData will contain a story that will have single and double quotes in it.

thanks
GK

Inserting An Image In A Access Table.
Hello everyone, i have this problem... i need to save an image into an Access (97..2003) database table field. I couldnt do it so i just saved the direction of the the file in the pc and everytime the user wants to read the image i just search in the database for the location and load it in a picturebox with LoadPicture... fine fine... but what i want is to actually sve the image in a (OLE - LongBinary type field)...

see i know there are some methods.. ehh.. GetChunk and AppendChunk but the thing is I AM getting the image from the user.. he selects the image from a OpenDialogBox.. ok all that is easy the thing is how I ::::--->


Code:
..
..
With rst
!TextData = "Sample String"
!NumericData = 123454321
!Image = ??
End With

Need Help Inserting At Bottom Of An Access Table Using VB 5.0
Need help inserting at the end of the Access table called "sales" & "accrec". It seems to randomly insert into the table. I would like to insure that it only inserts at the bottom. I tried the "rst2.movelast" & rst3.movelast but it doesn't do anything.

Thanks,
met12


Set dbs = OpenDatabase("c:vbinvenVB.mdb")
Set rst = dbs.OpenRecordset("SELECT dig6code, Numsold, Numleft, Description, Listprice, Cost, Datepurch from datainput;")

Do While Not rst.EOF

'add to accrec table
'dbs.Execute "Insert into accrec" & "(Acc, Invoice, Check, Invoicedate, Paiddate, Salescredit, Tax, InitialDebit, Balance) VALUES " & "('1212','2222','123123','5/7/2004','5/8/2004','MET','1.25','9.75','10.00');"
'rst1.MoveLast
Set rst2 = dbs.OpenRecordset("SELECT * from accrec;")
rst2.MoveFirst
dbs.Execute "Insert into accrec" & "(Acc, AccountName, Invoice, Check, Invoicedate, Paiddate, Salescredit, Tax, InitialDebit, Balance) VALUES " & "('" & acccode & "','" & accname & "','" & invoicenum & "','" & checknum & "','" & invoicedate & "','" & datepaid & "','" & salescredit & "','" & taxtotal & "','" & debittotal & "','" & balance & "');"
Set rst3 = dbs.OpenRecordset("SELECT * from sales;")


rst3.MoveFirst
dbs.Execute "Insert into sales" & "(Code6Char, Numsold, Item, Datepurch, Datesold, Invoicenum, Initials, Cost, Sales) VALUES " & "('" & Dig6code & "','" & Numsold & "','" & Description & "','" & Datepurch1 & "','" & datepaid & "','" & invoicenum & "','" & salescredit & "','" & Cost1 & "','" & debittotal & "');"
'dbs.Execute "Insert into sales" & "(Code6Char, Numsold, Item, Datepurch, Datesold, Invoicenum, Initials, Cost, Sales) VALUES " & "('" & Dig6code & "','" & Numsold & "','" & Description & "','" & Datepurch1 & "','6/1/2004','" & invoicenum & "','" & salescredit & "','" & Cost1 & "','" & debittotal & "');"

rst.MoveNext

Loop

dbs.Close

Inserting Rows From Textbox To Table
Hi,
I have been trying to insert textbox value to table.
Here is my code
x = Text1.Text
y = Text2.Text
MyConn.Execute ("INSERT INTO PUBLISHERS(Name,CompanyName) values ('&x','&y')")

If i use this code,the datas r not inserting from textbox,instead '&x' is added as one row in the table.
Can Anyone help me out..


vbado

Inserting Into A Table With An Autonumber Field
Hi,

Thanks for taking the time to look at this problem.

Using VB (and some SQL) I want to insert a new row into a table, the problem is the table has an autonumber field in it(its not the primary key though). When i do the insert statement it overwrites the number generated by the autonumber field (which I dont want), but if i leave it out an error occurs because there isnt a matching number of parameters ( eg the table has 2 columns and there for the insert statement must include 2 parametres)

Here is the code


VB Code:
DoCmd.RunSQL "INSERT INTO Sequence VALUES(" & IssuesNumber.Text & ", 0);"


IssuesNumber is the primary key

The 0 in the insert statment writes over teh autonumber unfortunately


I found this in the help file, but i cant make sense of it:

If you append records to a table with an AutoNumber field and you want to renumber the appended records, don't include the AutoNumber field in your query. Do include the AutoNumber field in the query if you want to retain the original values from the field.

Thanks
<>GT<>

Problem Inserting Into Access Table With Vb6
Guys

Can someone please take a look at this as I've been looking at it for hours and it's doing my head in!

this:


VB Code:
openCon     Set rsnewapp = New ADODB.Recordset     rsnewapp.Open "insert into newapplications (currentbankaccount, sortcode,accountno, visano,title,firstname," & _    "midname, surname,memnum, gender,dob,nationality,address1,address2,address3,address4,postcode,presentaddyears," & _    "presentaddmonths, std, hometel,mobile,email,memorablename,joint,prevaddress1,prevaddress2, prevaddress3," & _    "prevaddress4, prevpostcode, prevaddyears,prevaddmonths, jointtitle, jointfirstname, jointmidname," & _    "jointsurname, jointgender, jointdob, jointnationality, jointaddress1, jointpostcode, jointpresaddyears," & _    "jointpresaddmonths, jointstd, jointhometel, jointmobile, jointemail, jointmemorablename, jointprevaddress," & _    "jointprevpostcode, jointprevyear, jointprevmonths, maritalstatus, numberofchildren, mortgage, resstatus, bankBSoc, banksortcode," & _    "bankaccountno, accountname, bankyears, bankmonths, bankaddress1, bankaddress2, bankpostcode, chqgtecard, " & _    "coopvisa, diners, storecard, access, visa, amex, savingsfurtherinfo) values (strAppString);", conn     clsCon


in debug.print looks like this


VB Code:
insert into newapplications (currentbankaccount, sortcode,accountno, visano,title,firstname,midname, surname,memnum, gender,dob,nationality,address1,address2,address3,address4,postcode,presentaddyears,presentaddmonths, std, hometel,mobile,email,memorablename,joint,prevaddress1,prevaddress2, prevaddress3,prevaddress4, prevpostcode, prevaddyears,prevaddmonths, jointtitle, jointfirstname, jointmidname,jointsurname, jointgender, jointdob, jointnationality, jointaddress1, jointpostcode, jointpresaddyears,jointpresaddmonths, jointstd, jointhometel, jointmobile, jointemail, jointmemorablename, jointprevaddress,jointprevpostcode, jointprevyear, jointprevmonths, maritalstatus, numberofchildren, mortgage, resstatus, bankBSoc, banksortcode,bankaccountno, accountname, bankyears, bankmonths, bankaddress1, bankaddress2, bankpostcode, chqgtecard, coopvisa, diners, storecard, access, visa, amex, savingsfurtherinfo) values ("","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",False,"","","","","","","","","","","",0,0,0,0,0,0,0);


but I get an error message telling me that the number of query values and destination fields are not the same.

Thing is, they are. Another thing is that if I try to run the above query in Access I get a validation violation error, although there are no validation rules set on the table.

Inserting Value In MS Access TABLE (SIMPLE)
Hello Everyone
Simple problem: Trying to create a user account, with encrypted password with the following code. When the program starts it checks whether the table is empty or not, if it is it asks the User to create a User Account, my problem is that when I create the Account & press the Command Button (cmdCreate) its not inserting the values in MS Access Table. Currently I want only one & one entry into the Table, so thats why I'm using RecordCount=1 but I guess thats what is not working, if I remove that, it keeps adding the user name & passwords into the Table but I just want one. Please help.

VB Code:
Set dbLogin = OpenDatabase("d:
et doctordb2.mdb")        Set rstLogin = dbLogin.OpenRecordset("Access", adOpenDynamic)        With rstLogin        .OpenRecordset        While rstLogin.RecordCount = 1        rstLogin.AddNew        rstLogin.Fields(0) = Trim(txtUsName.Text)        rstLogin.Fields(1) = strEncrypted        rstLogin.Update        rstLogin.Close        Wend        MsgBox "You have successfully created a New User account, please remember your New User Name And Password", vbInformation        Unload Me        frmLogin.Show        End With    Else        MsgBox "Passwords Dont match please re-ENTER", vbCritical,     End If

Problem Inserting Table To Ms Word Using Vb
Anybody noe how to insert data into ms word table?
thanks

Trouble Inserting Record Into Table.
Hey, I can create my table in my database and everthing else, but I'm having trouble inserting the records. Can someone tell me what's wrong here? I don't get any errors, but when I open the table in Access, there are no records. Here's my code:
VB Code:
'connect to the databaseDim Cnn As ADODB.ConnectionDim SQL As StringSet Cnn = New ADODB.ConnectionCnn.Open ConnectionString:="Provider=Microsoft.Jet.OLEDB.4.0;" & _      "Data Source= c:windowssystemkamo.mdb;" 'set table = to the category addedtable = txtcategory.Text 'Loop through the filelistbox getting info on the filesMusicMaster.File1.Path = txtpath.TextOn Error Resume NextFor x = 0 To MusicMaster.File1.ListCount - 1    fname = MusicMaster.File1.Path & "" & MusicMaster.File1.List(x)    Call ReadMP3(fname, True, True)    'Store the MP3 info as strings    strFilepath = fname    strFileName = MusicMaster.File1.List(x)    strFileSize = FileLen(fname)    strArtist = GetMP3Info.Artist    strTitle = GetMP3Info.Songname    strAlbum = GetMP3Info.Album    strTrack = GetMP3Info.Track    strFrequency = GetMP3Info.Frequency    strBitrate = GetMP3Info.Bitrate    strLength = GetMP3Info.Duration        'Use SQL to insert the information in the strings into the tableSQL = "INSERT into " & table & " (Filepath,Filename,Filesize,Artist,Title,Album,Frequency,Bitrate,Length,Track#)VALUES ('" & strFilepath & "','" & strFileName & "','" & strFileSize & "','" & strArtist & "','" & strTitle & "','" & strAlbum & "','" & strTrack & "','" & strFrequency & "','" & strBitrate & "','" & strLength & "')" Next   'do the same thing for each item in the filelistbox  'Update the combocategory on the main formCall WriteTextFile  'this is irrelevant to the SQL stuff- Igore it.  

Inserting Pictures In A Word-table
Hello,

I'm generating a pricelist in Word. The different articles are placed in a table. The third column has to be a picture of the article. But how do I insert a picture in a cell of a Word-table.

Inserting Data Into A Joint Table
I am connection to a pevasive sql database.
I have two tables one cotain department info such as deptkey,deptId,deptName

The other contains Group Info such as , Groupkey, DeptKey,GroupID.

Since the group is related to the department it is given the deptkey for the department it a part of.

I want to know how to insert a user and password in to the departmaent that I will select fron a combo box and one or more groups That I will select from a list box.

So if I select a department and select one or moer group that is apart of that department the user I added shoul be a part of the department as well as the selected groups.

I select the groupID from the combo box
and the groupID from the list box

Thanks

Inserting Data Into SQL Table Efficeintly
Below is a sub that I am using to write data received from modbus connection to a PLC. I am using the data to keep history file in a SQL database. To be of any use the data mus be gathered very frequently and written in to database ver often. Is there a more efficeint way of writing this data t SQL than the method below. It looks like my loop times ar around 11 to 12 seconds and need to be 1 to 2.



Private Sub WriteDigitalDataToSQL()

Dim ConnectionOne As ADODB.Connection
Dim rstHistory As ADODB.Recordset
Dim ConnectionString As String
Dim SQL As String
Dim i As Integer
Dim DataType As String
Dim ServerName As String
Dim Database As String
Dim Count As Integer



ServerName = "10.1.1.2"
Database = "WIG"

Set ConnectionOne = New ADODB.Connection
ConnectionString = "driver={SQL Server};server=" & ServerName ";database=" & Database & ";UID=sa;PWD="
ConnectionOne.Open ConnectionString
Set rstHistory = New ADODB.Recordset
rstHistory.CursorType = adOpenKeyset
rstHistory.LockType = adLockOptimistic

i = 0
Count = 0

If Mod1.Result = 0 Then

Do While i < 480

DataType = "Digitals"

If chkVbDigitalTable(i).Value = 1 Then
SQL = SQL + "Insert into history values (" & "'" & Now & "'" "," & "'" & DataType & "'," & i & "," VisualBasicReceiveDigitalsTable(i) & ")"
Count = Count + 1
End If

i = i + 1

Loop



rstHistory.Open SQL, ConnectionOne



ConnectionOne.Close

If rtbLog.Text = "" Then
rtbLog.Text = Now & ": " & "Added " & Count & " digital items t the history file"
Else
rtbLog.Text = rtbLog.Text & vbCrLf & Now & ": " & "Added " Count & " digital items to the history file"
End If

Else

If rtbLog.Text = "" Then
rtbLog.Text = Now & ": No digital items written...loss o communication"
Else
rtbLog.Text = rtbLog.Text & vbCrLf & Now & ": No digital item written...loss of communication"
End If

End If



End Sub

Inserting Records From Datagrid To Table
Hi all, I'm here in a situation where I want to insert the record whichis in my datagrid, into a table in my database. can any one guide me howto loop through the records of the datagrid rows and insert them intotable.. I actually want to insert record into master table which is intemp table. both the tables have 4 colums..



plz help me out with this.. thanx

Inserting Data In Table With Foreign Key
hi,

i have form "Order Entry" with a subform "Order item". The order item is a weak entity with Order Number from Order Entry as primary key and Item Number as partial key. when i enter data in the Items sections, it gives error "Index cannot be null"
I have probably have to set the Index key for Item as the Order Number, but i dont know how to do it.

thanks a lot,
zuber

Inserting Image In Mssql Table ???
heloo frns ---- a very happy new year


can some tell me how to put image (.jpg or .gif) file in image in field in mssql table.

am taking this image from other database(mysql - blob field) or if it is null then directly through user input.


can some help me -----

Inserting Object Into Access Table Using VB
Hello everyone,
I am trying to insert an object into an access table using visual basic. I have set up a table and have a field that can hold objects. When I right click on the field and go down to "insert object" I can select the object (Excel File) from the filechooser I can insert just fine. I have no idea how to do this using visual basic.
Hope someone can help!

Thanks!!

Inserting A Field In An Access Table
Hi.

How do you insert a field in an Access table using VB code? In my app, I have a form which imitates Access' Design View, which is provided so that users don't have to use Access anymore. My problem is when the user wants to insert a field(s) between existing fields. I used the "Alter Table Add Column <ColumnName>" statement but the field is added at the end of table. That's why if I display the structure of the table which the user is modifying, the field appears at the end. When I verify the database and open the table involved, the field was really added instead of inserted. What code will I use to do just this? Is there a "Alter Table Insert Column" statement?

Thanks in advance!

Inserting Data From Array Into MSAccess Table
Hello, I would like someone to look at my code and give me some suggestions on how I could make it more efficient.

I am developing a MSAccessXP application that uses data on a SQL server. Since this is for use a laptop that will sometimes be disconnected from the company network, I need to fill tables in the Access database with data from my SQl database. I've tried several methods to do this, the one I am working with now works good but I think it's a little slow inserting the data into the Access table.

Here is the procedure for retrieving data from SQL server (This is in a class module):

Code:
Public Function GetCustomerArray() As String()
On Error GoTo err1
' Declarations
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim i As Long
Dim count As Long
Dim strCustomer() As String
OpenConnection 'Call custom sub to open connection to SQL Server
rs.CursorLocation = adUseClient 'Prepare and fill recordset
rs.Open "SELECT * FROM uvwCustomer", cn, adOpenKeyset, adLockOptimistic
count = rs.RecordCount
ReDim strCustomer(count) 'assign upper bound to array
For i = 1 To count 'loop through recordset to fill array
strCustomer(i) = rs(0)
rs.MoveNext
Next i
GetCustomerArray = strCustomer 'return array
ex1: 'Exit routine
CloseConnection
If Not rs Is Nothing Then
Set rs = Nothing
End If
Exit Function
err1: 'Error handling
MsgBox Err.Description & ", " & Err.Number
Resume ex1
End Function
This procedure is pretty quick. I've found in my tests that returning an array instead of a recordset seems to be quicker in the calling procedure.

Here is the procedure for filling the Access table with values from the array:

Code:
Public Sub FillCustomer()
On Error GoTo err1
'Declarations
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim i As Long
Dim strCustomer() As String
Dim oData As clGetData
Set oData = New clGetData
With cmd 'Clear tblCustomer
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "DELETE * FROM tblCustomer"
.Execute
End With
strCustomer = oData.GetCustomerArray 'Assign value of method to array
[b]For i = 1 To UBound(strCustomer) 'loop through array and insert values into
With cmd 'MSAccess table.
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdText
.CommandText = "INSERT INTO tblCustomer (CustomerName) " & _
"VALUES (?)"
.Execute Parameters:=strCustomer(i)
End With
Next i[/b]'Exit routine
ex1:
If Not cmd Is Nothing Then
Set cmd = Nothing
End If
If Not oData Is Nothing Then
Set oData = Nothing
End If
Exit Sub
'Error handling
err1:
MsgBox Err.Description & ", " & Err.Number
Resume ex1
End Sub

The highlighted block take about 5 to 6 seconds to execute. That may not seem like much but for this test I'm using a small table (222 records) with one column. When I start using larger queries with more records and multiple columns this going to get slow. I would like to know if there is way to assign an array or recordset to a Access table like you can with the recordset properties of forms and reports.

Anyway please take a look and give me some suggestions on how I might do this better.

Thank you

Warren

Inserting Specific Excel Table Into Word
Hello,

I'm new to the VBA stuff, done a little VB6.0 but here is my question. I want to create a table in Word by clicking a button(that I will make and insert into a tool bar). The idea is that when a user is typing along and wants to make a certain style table he will go and click this button, and the table will be inserted into the Word document where they are typing. The user can then input info into the table. Also, what I want to do is that after the user is done typing this document(lets say it's over 200 pages with 50+ tables) I want them to be able to press another button and the document will find all the tables, gather the information in the table and create a text(with .txt extension) with some of the info in all those tables...I know how to gather the information from a table(that is currently in Excel) and print out the text file...I just need help with all the stuff before that... Thanks in advance for your help!

Skilit
Ok well I figured out how to create a general table, but I want a certain format for some of the columns and insert predefined text in a particular row...any takers?

Inserting Word Table &amp; Fields Into A Document
Does anyone know how to insert a Word table and fields into a document programmatically?

I am trying to write some VBA that reads a text file. For every record in the text file, the program should insert a new page with a table & fields.

I tried creating a template, but that would require me to have two different documents.

Any help anyone can provide would be greatly appreciated.

Thank you.

Inserting An Excel Sheet As OLE Obj Into Access Table
Hi, I desperately need help with this,

I have an acces table for employees. One of the table fields contains an excel spreadsheet. For ech employee it is the same spreadsheet, but they each have their own copy.

My problem is I have created a form to add a new employee to the table, with text boxes etc for entering the name, employee dept etc. When the submit button is pressed these details are inserted into the table, using the DoCmd.RunSQL method and an INSERT...INTO query. However I dont know how to insert the excel sheet into its appropriate field.

Can anyone tell me how to do this with VB?(, or if theres any SQL experts out there can it be done with an INSERT or UPDATE query?)

Any help on this is most appreciated.

Thanks
Andy

HELP!!! Inserting String From Data Field Into SQL Table
Hi,

Am new to VB - and this will seem like a very stupid question to most of you...

I need to update a field within an SQL table. Let's say Col 1.
The new data comes from a text field called txtData and then should be inserted into Col1, when clicking on update.
However- although I know how to insert in a file... I do not know the code on how to insert direct into an SQL table. Let's say this table is called test ...

any thoughts ??
thanks

Copyright 2005-08 www.BigResource.com, All rights reserved