Problem reading textboxes

C

ChoonBoy

Appreciate help on this issue. Thanks in advance

The objective is to switch to any BE using the textboxes and ok button below.


- I have a form named ChangeLink
- 1 textbox named txtpathOld (value = c:\rmetms\etmsbe.mdb")
- 1 textbox named txtpath (value = c:\rmetms\reps\etmsbe1.mdb")
- 1 textbox named txtpw (value = blank1)
- 1 button named cmdok

The code behind the cmdok (this works)

-------------(Part only)------------------

If Len(.Connect) > 0 Then

If.Connect = ";DATABASE=c:\rmetms\etmsbe.mdb" Then

.Connect = "MS Access;PWD=blank1;DATABASE=c:\rmetms\reps\etmsbe1.mdb"


.RefreshLink


The code behind the cmdok (does not works)

-------------(Part only)------------------
Dim Path As String
Dim PW As String
Dim PathOld As String

PathOld = Forms![changelink]!txtpathOld
Path = Forms![changelink]!txtpath
PW = Forms![changelink]!txtpw

If Len(.Connect) > 0 Then

If.Connect = ";DATABASE= Forms![changelink]!txtpathOld Then

.Connect = "MS Access;PWD=pw;DATABASE=path"


.RefreshLink


The error message "Not a valid filename" and when I clicked debug it
highligh .RefreshLink.

Thanks
 
J

John Smith

It's saying "Not a valid filename" becuase you are telling it to look for a
file called "path". If you want the value of a control added to a string
rather than it's name then you have to join the control to the string not name
it within it. Also if the code you give is a true copy of your code then it
would not even compile as you have a missing space and only one double-quote
in the criteria.

Try this:

If Len(.Connect) > 0 Then
If .Connect = ";DATABASE=" & txtpathOld Then
.Connect = "MS Access;PWD=" & txtpw & ";DATABASE=" & txtpath
.RefreshLink
End If
End If

HTH
John
##################################
Don't Print - Save trees
 

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