Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data base control via script 1

Status
Not open for further replies.

Geo45

Technical User
Jul 17, 2002
19
GB
In a form I have written a function, that edits a string passed to it and then it returns a new string

the function is like this

function name(inputstr as string) as string
name = inputstr + " is cool"
end function

in the database file lets call it "DB1"
it contains

name text field
sir-name text field

their are currently 10 records. I want to start from the first record to the last using this function to change the name field

IE

record 1 before after
name john john is cool
sir-name pip pip

record 2
name dave dave is cool
sir-name kul kul


and so on to the end

I hope this makes sence
 
Geo,
First off, I recommend that you mark this thread for email notification - since I dont see your name on the list of marked people.
Second, don't be shy with us at Tek-Tips! Just paste the code that you have written RIGHT ON IN... I'm looking at your sparse code up there and I'm more confused than if you had just pasted your code. Best way to help us help you is to be brutal with us.. give us an hour long book to read... believe me - we'll sit through it, this site has helped us all enough ... we love returning the favor. I suggest rewording and reposting.
Lastly, I think you are going to need to use RecordSets to accomplish what you're attempting.

Recordsets are fairly easy, but can be extremely complex.
A basic recordset opening looks like this..

Function Recordset()
Dim DB As Database
Dim RS As Recordset
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("tblMyREcordset") 'query or table
Do While Not RS.EOF ' Keeps loopin till no records left
RS.Edit
RS.MoveFirst
RS![Field1] = txtBox1 ' sets the field equal to the info in the textbox
RS.Update ' Updates the record
RS.MoveNext
Exit Sub
End With
Loop
Set DB = Nothing
Set RS = Nothing
End Sub

I just threw a few RecordSet methods in there so you can get a feel for it. You should read up on them! They are awesome tools! You'll need to edit it... you might not want the loop, or whatever.. if you don't want the loop replace 'DO While Not RS.EOF' to 'With RS' and replace loop with 'End With'.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top