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




Opening A Text File In Append Mode?


I have a program where I am checking for the existence of a file. If the file exists, I wish to open it in "Append" mode where I can add records to already existing records. If the file doesn't exist, I will open it in "Output" mode. Problem is the file should contain previous data and it does'nt.

How can I open a file and maintain it's contents?

Thanks,
Jeff




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Writing At The 'beginning' Of Text File (append Mode)
Hi all! I try to write to text file using these codes below:


Code:
Dim fnum As Integer
dim str as String

fnum = FreeFile()
Open "c: est.txt" For Append As #fnum

Print #fnum, str

Close #fnum

Instead of using Output mode, I'd like to use Append mode. But append mode always adds new data at the end of file. How can I move the pointer so I can add new data at the beginning of file?

Thank you very much! Regards.

Write Text File Binary Append Mode
Hi

I am using following code:


vb Code:
Public Sub PutTextToFile(ByVal sFile As String, ByVal sText As String)    'Writes text to file sFile    'Example usage: Call PutTextToFile("C:Programs.txt", "test")    Dim I As Long    On Error GoTo PutTextToFile_Error     I = FreeFile    Open sFile For Binary Access Write Lock Read Write As #I    Screen.MousePointer = vbHourglass    DoEvents    Put #I, , sText    ExitHere:    On Error GoTo 0 PutTextToFile_Error:    Close #I    Screen.MousePointer = vbDefaultEnd Sub
It overwrites the existing file. Instead, I want to append the new text to an existing file. How can I do that?

Please help

Writing At The 'beginning' Of Text File (append Mode)
Hi all! I try to write to text file using these codes below:

Code:Dim fnum As Integer
dim str as String

fnum = FreeFile()
Open "c: est.txt" For Append As #fnum

    Print #fnum, str

Close #fnum

Instead of using Output mode, I'd like to use Append mode. But append mode always adds new data at the end of file. How can I move the pointer so I can add new data at the beginning of file?

Thank you very much! Regards.

Opening A File To Append To?
My code:

Where text16.text is the name of a person
and text21.text is the sum of all the information
gathered from the program.

I create a folder and then the file within the folder

If fs.FileExists("c:employee_review" & Text16.Text & ".txt") = False Then
Set a = fs.CreateTextFile("c:employee_review" & Text16.Text & ".txt")
End If

All the text information is compiled and formatted into text21.text


Open "c:employee_review" & text16.text & ".txt" For Append As #1
Print #1, Text21.Text
Close #1

How do I recall the name of the new file using the "open command" to append the contents of text21.text into this new file?

Opening A File For Input & Append?
Is it possible to open a file for input & append at the same time?

Opening A File In Read-only Mode
Hey there. I'd like to open a file I'm using in Read-Only mode, but I'm not sure how to do this. Currently, I open the excel file using this procedure:


Code:
Public Sub LoadExcelAnt()
Set Active_Excel = CreateObject("Excel.Application")
Set Active_Workbook = Active_Excel.Workbooks.Open(FileName)
Set Active_Worksheet = Active_Workbook.Worksheets(1)
Active_Excel.DisplayAlerts = False
End Sub

So, what do I set to make it Read-Only?

Opening File In Binary Mode
I am right in saying that the following code will open a non-text file and load the contents of the file into a string called TextLine arent I?


VB Code:
Open ResultsArray(5, Index) & ResultsArray(0, Index) For Binary As #Filenumber            If Err.Number = 0 Then                TextLine = String(LOF(Filenumber), " ")                Get #Filenumber, , TextLine                  '                  '                  '                  '  


Cos im doing a search thru a directory of 44 files for "abc" using instr on the textline field but its only returning 14 files whereas the windows search is returning 41 so Im puzzled

Thanks peeps

Opening A File In Binary Mode For Appending?
Ok I want to open a file in binary mode so I can write out a binary array of data to the file. The file could be anywhere from 4KB to 100MB in size. I want to append the data though and not destroy what is already there.

I could read the entire file into memory, append the new data, and write the file back out but I want to avoid that.

Is there a way to open a file in binary mode so I can append data to it? Is there something similiar to

VB Code:
Open FilePath For Append as #1


That will work with binary access?

Opening A Sequential File For Read Access In Shared Mode
Does anyone know if there is a way to open a sequential file for
reading (Output) in a way that the file could be opened for
other processes at the same time for reading. Using either the
File System Object or the older Open "C:MyFile.txt" For Output
As #MyFileHandle approach.

Here's a little context.

I am writing a VB6 program that needs to be able to open up a
text file read a specified number of records and Insert them
into a database. The file is quite large and we would like to be
able to run muliple instanses of this loader program. Either
from one server or from multiple servers while accessing the
same input file. For instance... the first instance of the
program would open the input file and read the first 20000
records inserting them into the database. At the same time a
second instance of the same program would be launced adn it
would read records 20001 through 40000 and intert them into the
database through a separate DB connection.

I must admit I haven't simply tried doing it concurrently using
either the FSO or the older approach so I don't know if it opens
the input file for shared access already.

Thanks for any assistance,
Doug

Help With Append Mode
Hello!
I am trying to save file for append and although the following code works it saves it onto the same line as the previous entry. I want it to save entered data on a new line. Could someone tell me whats wrong! Thank you!
Heres the code..

Private Sub cmdstorenew_Click()
Open "N:my pictures/customers.txt" For Append As #1
Write #1, txtcarcomp.Text, txtcustaddress.Text, txtcity.Text, txtpostcode.Text, txtphone.Text
savenew = True
If savenew = True Then
Open "N:my pictures/cars.txt" For Append As #2
Write #2, txtnewreg.Text, txtcarmanu.Text, txtcarcomp.Text, txttyretype.Text, lbldate.Caption
End If
Close #1, #2
End Sub

Append Mode
hi i got problem how to append file using file system object
i try to use this code it works for append but when the program closes and i want to append again in the same file, it rewrite all. is there any tips how to make program can append text all the time not when the program runs?

Dim kStreamWrite As TextStream

Set kStreamWrite = gfso.OpenTextFile(logstring, ForAppending)
kStreamWrite.WriteLine "Hello world"

'Close all objects
kStreamWrite.Close

Read And Append Text File Details To Onother Text File
i have three text files and i want to read staff from the other two and append it to one .how do i do it??

when opportunities arises ,only the prepared mind is fovoured

Clipboard In Append-Mode
Hi all,

is there a possibility to append data to the clipboard?
That means when I copy for example the string "foo" to the clipboard and the copy the string "bar" I want the result "foobar".
Thanks in advance

RESOLVED Read Text File And Append Into Another Text File
I have a text file named names1.txt.... The contents of the names1.txt file is as follows:


Emp id:"B1234"
Emp id:"246810"
Emp id:"B88888"
Emp id:"B55555"
Emp id:"111555"

I want to read the text file and take the value from between the " " where the first character after the " is a letter b followed by a number and append this value into a new txt file named Final.txt.

Final.txt would look like this:

"B1234"
"B88888"
"B55555"

It took only the values between the " starting with B followed by a number...

Need To Append A Text File (delete Some Text Then Save)
Using VB.Net
Im trying to open a text file, Delete all text beginning with "Game St" and Ending in "ths )". (this includes all text in between).
Then save the textfile with changes.
Ive exhausted all brain cells trying to do this.
code help here please?

How To Append To Text File
Hi all. First I'd like to say that this has been a really useful forum for me since I recently began learning VB. When I've had questions, searching has usually brought up just what I need.

But for this question I'll have to ask some of you for suggestions.
Basically what I'm trying to do is write the contents of a text box to a text file.
I open the file, print the time and date, the contents of the text box, and then close the file.
My question is:
How can I add some sort of separator line (for example, "---------") right before I close the text file. Right now I could add a line right before Close, but that would just put a line every time I add text. I just want to separate one connection from the other.

Here's my code:

Code:
Private Sub cmdDo_Click()
Dim strHoldData As String
strHoldData = txtWrite.Text
txtData.Text = txtData.Text & vbCrLf & strHoldData

Dim tCurrentTime
Dim MyDate
tCurrentTime = Time ' Assign a time
MyDate = Date ' Assign a date
Open "E:Documents and Settingsjason.100ACREMy Documentsprogrammingvb6TESTING.txt" For Append As #1
Print #1, "connection time: " & tCurrentTime
Print #1, "connection date: " & MyDate
Print #1,
Print #1, txtData.Text & vbCrLf
Close #1

txtWrite.Text = "" 'set textbox to blank
txtWrite.SetFocus

End Sub

Hope that you can understand what I'm getting at here.
Would appreciate any help or suggestions.

Electioniering

Help To Append My Text File....
Hi.......!

Can anyone help me with this one.........?

I have a program that writes a line of data to a text file each time the machine shuts down.

I want this line of data to be Appended to another text file so that the data becomes Sequential in the second text file?

Thanks for any Help!

Append Text File
i need to have a my data that is that is in text1 box saved to a txt file and have it append it to the end of what is all ready there?

Append Text File From Top
how to append text file from top...



eg time.txt

-->>insert new text (9.00am)
-->8.00am
-->7.00am
-->6.00am

How To Append In A Text File?!!!
I would apprecitae if you tell me how I can append some lines into an existing text file using visual basic.
the added lines should be inserted into the first line
thanks in advance

Reza

Append Text To A File
i can never remember how to write to files properly.

i need to loop through a recordset, appending some text to a file on each loop. at the moment i have this:


VB Code:
Do Until (.EOF)  Open "file.txt" For Output As #intFreeFile    Write #intFreeFile, GetSomeText(!field1, !field2)  Close #intFreeFile   .MoveNextLoop


but that just overwrites it each time

Append Text To A File
Hi ALl,

I want to appned text to text file through visual basic application.
Please note that I dont want to overwrite the text file. But I want
to append new text to the existing text file.

How to do ?

Gunwant

Append A Text File
Hello,
How can I append the contents of one text file to another text file without overwriting the contents of the second File
Thanking You
Kalyan

 

Cannot Append Text To Previous File
I'm able to create the file but everytime I try to append text to it, it erases the first line. Here is the code


Code:
Dim fso, TStream
Dim FileName As String
Dim FileMessage As String

Set fso = CreateObject("Scripting.FileSystemObject")
FileName = "Log File.txt"
Set TStream = fso.OpenTextFile("C:" & FileName, 2, True)
FileMessage = "Test"

Call TStream.WriteLine(FileMessage)

Any ideas?

Append To Each Line In Text File..
I have a list of files on a text file that I need to append to on each line.
This is how I am inputing the text file for now.


Code:
Dim i As Integer
i = 1
Dim strData As String
'j = j + 1
'Dim var As String

Open List1.Text For Input As #1

Do
'For a = 1 To i

Line Input #1, strData
List2.AddItem strData
Loop Until EOF(1)
Command2.Enabled = False
MsgBox "End of File reached"
Close #1

Each line is placed on the List2box. All lines look like this:

C:windowssystem32"name of a system file" SysFileA

Next line is
C:windowssystem32"name of a system file" SysFileB

and so on.

I need to append the word "SysCheck1" & "File" to the beginning of each line, remove the letter "C:" and replace it with /hd0, and also change all the "" to "/". In addition, increment the "SysCheck1" string to "SysCheck2" and so on for each line.
Example:

This line:
C:windowssystem32"name of a system file" SysFileA

Would become this line:
SysCheck1 File /hd0/windows/system32/"name of a system file" SysFileA

Next file would be:
SysCheck2 File /hd0/windows/system32/"name of a system file" SysFileB
and so on...

I know I can use the Replace function but appending to each line in the beginning and incrementing the first string is where I am lost.

Thank you.

Append Text File But Without Duplicates
Hi everyone,

I am totally new to Access (have a tiny knowledge of Excel VBA but this isn't helping me with this).

Two questions, I need to import over 150 text files daily into 2 tables within Access. The data has to append, but not import duplicate rows. I have worked out how to do the first part - (albeit one file at a time) but I don't know how to get it to ignore duplicate rows;

Option Compare Database
Function Macro2()
On Error GoTo Macro2_Err

DoCmd.TransferText acImportDelim, "myspec", "myatextfiles", "C:myATextFile01.txt", True, ""

Macro2_Exit:
Exit Function

Macro2_Err:
MsgBox Error$
Resume Macro2_Exit

End Function


Secondly, is there a way of importing multiple files which sit in a specified folder? There are 75 files with the following name: myATextFile01.txt, myATextFile02.txt, myATextFile03.txt....and so on 'A' being the key to which table it should append to in Access. The second set of files are the same, but with 'B' as the identifier; myBTextFile01.txt...

Any help/advice would be most appreciated

File Text Write/append To
I have a project that im working on that does several things and i want everytime that it finishes to write a line to a text file (event log)

here is my module sub


Public Sub SaveText(FileNam As String, TxT As String)
On Error GoTo newfile
Open FileNam For Append As #1
Print #1, TxT
Close #1
Exit Sub

newfile:
Open FileNam For Output As #1
Print #1, TxT
Close #1
Exit Sub
End Sub


then i call it..
call savetext("c: estinglog" & date & ".txt", "event")

when i do this i get an error "file not found".. shouldnt VB create the file if not found? if not, anyone help me make it create the file if not found?

2nd.. i want the file to be hidden, any ideas?

thanks in advance.

How To Append Data In Text File In Vb 6 By Using DAO
hello my self avi developing one industrial related software. here i m using DAO liabrary. i want to transfer some my data in text file. i dont know any thing about file handling in vb. so please some one help me
How To Open text file
How To Append Data
How To check out file all ready exit or not
plz hekp me

How To Append Text Into Text File List ?
I have this text file, about 500 lines long of names and i want to add print #" to the start of each entry,

Well my list may be

cat
dog
mouse
fish
carrot etc,

so i want it to become

print #1 "cat
print #2 "dog
print #3 "mouse
print #4 "fish etc.

I have looked but still cant find an answer.....

Append New Text Line To Text File
I want to open a txt file through my access database and append a line to it. When I use the opentextfile method for appending but it always appends my new text line to the end of the last line. I want it to append the new text to a new line. I have tried object.skipline but this is not supported when appending?

This is what I get:
"oldline" "newline"

but I want:
"oldline"
"newline"

Here is my code

sub ConcatenateTxtFile ()

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fd.OpenTextFile(dpath, ForAppending)
'Need a line here to skip to next line
f.writeline ("newline")

End Sub

How To Append A Text File In An Existing Excel File
Hi!

I am getting some problem in appending a text file in my existing excel file. All I want to write a Macro which will read my text file and append the fields from the text file to existing excel file.
Can someone help me???

I would really appreciate that.
Thanks.
Jit

Run Macro -Append Text File (Send File Name)
I am using the following code to run an Access2000
Macro from VB6.
It run perfectly ok.

Dim A As Object

      Set A = CreateObject("Access.Application")
      A.Visible = False

      A.OpenCurrentDatabase ("C: estTest.mdb")

      A.DoCmd.RunMacro "Macro1"
      
      MsgBox ("done")


The macro is an append text file to a access table
If i include the name of the import text file
eg  File Name     c: est
ed.txt
It works fine.

But,,,
I need to nominate the name of the file i need to import
ie. send the macro the name of the file name.

Appreciate any advice as to how to achieve this.

Regards  Kennedymr2


How To Read From Text File And Append It To Excel File
could somebody pls help to read from a text file
and append the content to excel file.
the text file format is like this:

abs,123
aaann,89
1111,ybk

and i want to append it to excel file

col1 col2
abs 123
aaann 89
1111 ybk

please help

Open, Search And Append In Text File
This is the content of my text file:

Project
Job
Task
Information

I want to open this file, then search for a keyword (e.g. Job), and then append a string at the end of THAT line, where the keyword has been found.

For example: the keyword is "Job" and the string I want to append is "-Analyse"

the text file would have to become:

Project
Job-Analyse
Task
Information

I'm looking for the VBA coding for this. I'm using Excel 2002 (dunno if that matters).
I tried all sorts of things but couldn't get it to work.

Append Text File To Access Database
Hi,
I hope i'm posting in the right forum. I was wondering if anyone can give me some tips how how to append a text file to an Access database. My text file is written in notepad. Used semicolon(";") as a delimeter. I want to take the record in the text file and append them to the existing records in the Access table. I want to use vb to create a program that will do this. I never done anything like this before so i dont know how to start.
Do i open the text file and place the records into a 2 dimensional array and then save it to the access table? Is it possible to do this? Or is there a better way?

Thanx in Advance
Steffy

Append Text To An Existing Internet File
I have a url of a file that is read/write to all: http://...../filename.txt

By entering this URL in the IE you are prompted to save it to disk without having to enter a userid/password, so the file is publicly available.

What I want to do is open it and append text to it- I'm trying to write to a log file that already exists at this URL when a user updates his/her workstation.

How do I use the HTTP internet functions to open this file and append text to it? I have been using wininet.dll functions and need to stick to this.

I have tried all of the tricks with HttpSendRequestEx, InternetWriteFile, etc, however I have not found an article that addresses this particular situation.

Maybe what I am attempting is not possible? I don't want to use the FTP interface because that requires a username/password combo and that would stop the automatic process of writing to the file behind the scenes because the user is not going to know why they are being prompted for a userid/password, but since the URL is already public, it can be directly accessed.

Thanks!

Append To Same Line In Text File Without Quotes
Is there anyway to have VB append text to a text file on the same line as many times as a user clicks a cmd_button and NOT put quotes around it? Here’s the code that I have, just so y’all can see what I’m doing. I’ve tried with FSO and without… same thing. Every time the user clicks “cmd_new” it adds the text to the file but on a new line instead of continous:

Regular:

VB Code:
'this is just a tester.. the actual file will be saved in the "my_creations" directoryOpen "C: xt.txt" For Append As #1   Print #1, txt_openfont.Text & txt_sel_font.Text & txt_close.Text & txt_opensize.Text & txt_sel_size.Text & txt_close.Text & txt_opencolor.Text & txt_sel_color.Text & txt_close.Text & txt_sel_charClose #1


FSO:

VB Code:
Dim FSO As New FileSystemObjectDim Stream As TextStream If Len(Dir$(App.Path & "my_creations" & txt_name.Text & ".txt", vbNormal)) = 0 Then   'file doesnt existSet Stream = FSO.CreateTextFile(App.Path & "my_creations" & txt_name.Text & ".txt")Stream.WriteLine txt_openfont.Text & txt_sel_font.Text & txt_close.Text & txt_opensize.Text & txt_sel_size.Text & txt_close.Text & txt_opencolor.Text & txt_sel_color.Text & txt_close.Text & txt_sel_charElseOpen App.Path & "my_creations" & txt_name.Text & ".txt" For Append As #1Print #1, txt_openfont.Text & txt_sel_font.Text & txt_close.Text & txt_opensize.Text & txt_sel_size.Text & txt_close.Text & txt_opencolor.Text & txt_sel_color.Text & txt_close.Text & txt_sel_charClose #1 End If


Any ideas?? Sorry for the REALLY wide post, lol

Append A Text Line To An Html File
Hi !!

I need create a form, and ineed what this be capable of append the content of a combo box like a "abcdefgh123456" to an html file in the EOF.


i can do it in a .txt file, using this code:

Private Sub Command1_Click()
Open "C:Test.txt" For Append as #1
Print #1, text1
Close #1
 
End Sub


but this don't work with :

Private Sub Command1_Click()
Open "http://site/www.html" For Append As 1
Print #1, "text1"
Close




Greetings!!



 

Append One Text File To Another Text File Using A VBA Macro
What code would be used to append one text file to another text file using a VBA macro?

ie: I have 10 text files (name, addresses are all stored in variables) and I want to make this into one text file, no changes, just one appended after another. I don't want to open them in Excel, I just want the VBA code to combine them all into one.

Is this possible?

A Tough One! - Import Text File As Append But Fields Dun Match
I have a database almost finished, but they just changed the format of the updates. Now the updates are delimited text files but the fields that are in the text file aren't in the same order as the database, how can i map the fields correctly?

Opening An EXE File Into A Textbox, Just Like Opening A Text File???
Hi,

I would like to open up an EXE file into a textbox using this code:

Open "C:Ascii.exe" For Input As #1
text1.Text = Input(LOF(1), 1)
Close #1

When I try that I get a message "Bad file number or number". What does that mean.

Thanks

Opening An EXE File Into A Textbox, Just Like Opening A Text File???
Hi,

I would like to open up an EXE file into a textbox using this code:

Open "C:Ascii.exe" For Input As #1
text1.Text = Input(LOF(1), 1)
Close #1

When I try that I get a message "Bad file number or number". What does that mean.

Thanks

Error Message With Opening Of A Text File And Inputing The Text Into Text Boxes
Hey all:

Here is the problem at hand. I have a procedure that opens a recently saved file and when executed places the contents of that file in the designated text boxes I have coded. But the thing is I am getting this error message during the process...

Quote: (Subscript Out of Range)

What does this mean?

Here is the code that I have so far... any help would be greatly appreciated.

Code: Private Sub mnuOpen_Click()
'Open a Previously saved file. Search values are suffixed with .txt
Dim r_strFileName As String
CommonDialog1.CancelError = True 'Set CancelError is true
On Error GoTo ErrHandler
    CommonDialog1.Flags = cdlOFNHideReadOnly 'Hide Read Only Files
    CommonDialog1.Filter = "*.txt" 'Set Filters
    CommonDialog1.DialogTitle = "Opening Saved Search - Locate Text File"
    CommonDialog1.ShowOpen 'Display the Open dialog box
    r_strFileName = CommonDialog1.FileName
    
'Existence Test
If Dir(r_strFileName) = "" Then
    MsgBox r_strFileName & "File Does Not Exist!", vbCritical
End If

'Read File
On Error GoTo Tag800_error
Dim intFreeFile: intFreeFile = FreeFile()
Open r_strFileName For Binary As intFreeFile
Dim strData As String: strData = Space$(LOF(intFreeFile))
Get intFreeFile, , strData

'Remove Ending vbCrLf
strData = Left$(strData, Len(strData) - 2)

'Format Data
Dim strText() As String: strText() = Split(strData, vbTab)
lblAI.Caption = strText(2)
txtDataString.Text = strText(3)
Linear.Text = strText(4)

'Exit
GoTo Tag900_Exit

'Error Trapping
Tag800_error:
    MsgBox "File Read Error" & r_strFileName & vbCrLf & "(" + Err.Description + ")", vbCritical
    Err.Clear
    
'Housecleaning
Tag900_Exit: ' Housecleaning
    On Error GoTo 0
    Close intFreeFile
    
ErrHandler:
    Exit Sub
End Sub


James

Copying A Text File From A Pocket PC To A PC In Binary Mode
I use the following code to copy a text file from a Pocket PC to a PC, in Visual Basic.

The text file is saved in a Byte Array called bytBuffer.

Open "C:eoordeling.txt" For Binary As intFreeFileID

For intWriteLoop = 0 To lngBytesRead

Put #intFreeFileID, intWriteLoop + 1, bytBuffer(intWriteLoop)

Next

Close intFreeFileID

When lngBytesRead has a value that's higher than 32500, I get an error that says "Overflow".

Is 32500 the limit for writing to a file in binary mode?

I've already tried to copy the file in 2 or 3 stages, but I still get the same error.

What's the solution for this problems, or are there any alternatives for copying a text file (aproximately 80 kb) from a Pocket PC tot a PC?

Opening Word For Append
I have just found out how to create a new instance of a word document, from MKoslof. The only problem is that the document is cleared each time before opening. That is, it opens a file the same way that the following code does:


Code:
open "My Output File.doc" for output as #1

But I would like it to open with the existing data, that is:


Code:
open "My Output File.doc" for append as #1

Can the following code be modified to allow me to append the word document rather than open it as a new file:


Code:
Private Sub Form_Load()

Dim objWord as object
Set objWord = CreateObject("Word.Application")

objWord.Application.Visible = False

objWord.Documents.Add
objWord.Documents(1).Paragraphs(1).Range.Text = "HEADER"
With objWord.Documents(1).Paragraphs(1)
.Alignment = 1
.Range.Font.Name = "Arial"
.Range.Font.Size = 20
.Range.Font.Bold = True
.Range.Text = "HERE IS MY HEADER"
End With

objWord.Documents(1).Paragraphs.Add
With objWord.Documents(1).Paragraphs(2)
.Alignment = 0
.Range.Font.Size = 12
.Range.Font.Bold = False
.Range.Text = vbCrLf & "Here is the date: " & Date
End With

objWord.Documents(1).SaveAs "C:TestDoc.doc"
objWord.Quit
Set objWord = Nothing

End Sub

I would like to adjust font size and other things so I would prefer to use the last peice of code. I do however, need to be able to add to an existing file, rather than create a new one.

Any thoughts would be appreciated.

Thanks.

How Do I Display Text Value For Indexed Combobox In Update Mode File Of LoadControls?
On an update form during initial data load of records to be processed I want to display the combobox text value for the record selected. On the initial load and as I scroll through the records the text value of the combobox should change based on the value in the master record column that contains the index value for the combobox index. All I can ever get to display is either the index number or the first text value of the combobox's record set. How can I get the corresponding text value to display?

Here is the initial load of the combobox record set:

Private Sub LoadSeminars()
   With mrsSeminars
        .Open "Seminars", gcnAP, adOpenStatic, adLockOptimistic, adCmdTable
        Do Until .EOF
            cboSeminars.AddItem !Seminar_Title
            cboSeminars.ItemData(cboSeminars.NewIndex) = !Seminar_ID
            .MoveNext
        Loop
        .MoveFirst
        cboSeminars.Text = !Seminar_Title
    End With
End Sub

Here is the load of the data to be updated:

Private Sub LoadControls()
 With mrsBrochures
        txtSeminar_ID = !Seminar_ID
        txtFromDate = !From_Date
        txtToDAte = !To_Date
        cboSeminar.?????????????? This is where I am stuck! Help
End With
End Sub

From the above you can see that I want to display the Seminar_Title for the Seminar_ID.

This one is driving me crazy! Thanks for your help!


 

*RESOLVED* Using Text File As String Input For Opening Other Text Files
OK, I've been banging my head trying to get this one little piece to work (that I had working prior to a loss of power on Friday) but I cant remember the syntax I used to get it right.

What I'm doing is opening 1 text file and using it as the input in a loop to open and parse mutiple text files to a text box.
Heres the part that doesn't work;

Code:
Open "rbt.txt" For Input As 1

Do Until EOF(1)
Open " " & rbt.txt & ".txt" For Input As 2 'THIS IS THE PART THATS not working !

Line Input #2, slist
s = s & slist & vbCrLf

Upt_log_txt.Text = s

Loop


I know its a syntax (read as placement) issue but I cant get the right combo down.
HELP !

Opening Forms In Add Mode
I am trying to use a button to open a form in add mode, so no records are displayed. This can be set when using a Switchboard but must be possible using a line or two of VB code. The current code for the button is:


Private Sub Button1_Click()
On Error GoTo Err_Button1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PAYMENTS"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Button1_Click:
Exit Sub

Err_Button1_Click:
MsgBox Err.Description
Resume Exit_Button1_Click

End Sub

Does anyone know how to change this, to open in add mode.

Thanks in advance

Opening A Doc In VBA In Shared Mode
Hi
I need to open a doc file in VBA in shared mode in W2k.FileOpen Opens it in locked read/write mode.How can i specify the lock.

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