Changing a field in a record using VB

L

Lionel Fridjhon

Fred
Thanks for the help - works fine!!

Next problem - I have a procedure which gives a user a
standard Windows dialog box to select a new file path to
the images.

This data is stored in a variable called "DataFilePath".

How can I replace the entry in the 1 record, 1 field
table called "tblFilePath" with this new string?

Lionel
 
F

fredg

Lionel said:
Fred
Thanks for the help - works fine!!

Next problem - I have a procedure which gives a user a
standard Windows dialog box to select a new file path to
the images.

This data is stored in a variable called "DataFilePath".

How can I replace the entry in the 1 record, 1 field
table called "tblFilePath" with this new string?

Lionel
Lionel,
Glad to see you changed the table and field names.

I can give you part of what you need using an Update query:

Dim strSql as String
strSQL = "Update tblFilePath Set tblFilePath.DataFilePath = '" & and
here I have to leave you as I don't know what you are getting the new
folder/path from & "';"

CurrentDb.Execute strSQL, dbFailOnError

Place whatever variable the new name is stored in after the first & sign
and in front of that last & sign, so that it becomes one string.
Something like:
strSQL = "Update tblFilePath Set tblFilePath.DataFilePath = '" &
YourNewPathVariable & "';"

Those quotes are
= ' " & YourNewPathVariable & " ' ; "

A good way to make sure the SQL is correct is to place a MsgBox in front
of the Execute line:
MsgBox strSQL

When you step throu the code the message should read:
Update tblFilePath Set tblFilePath.DataFilePath = 'c:\NewFolder\';

If you get that, (with the correct path, of course) then the SQL is OK,
otherwise make corrections as needed.
When done, remove the MsgBox line.
Run the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top