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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetSetting question

Status
Not open for further replies.

MDA

Technical User
Jan 16, 2001
243
US
Hi all,

I am having a problem with a GetSetting Function. I am saving the last DSN selected by a user in an ODBC connection form. Everything works fine, but if I delete the ODBC conection then run the VBapp I get a run time error 383 - "text property is read only"

My Syntax:
-------------------------
'Read in last DSN used
Dim lastdsn As String
lastdsn = GetSetting(App.EXEName, "Options", "DSN Name", "")
If lastdsn = "" Then

'Nothing

Else

cboDSNList.Text = lastdsn

End If
Exit Sub
-------------------------

If there is no 'lastdsn' (I.E. Deleted) the IF statement should be true. However, upon further checking, I found that the lastdsn is not pulling in an empty string but rather the NAME of the server I am connecting to?

Any ideas on how to avoid this error I am getting. Basically I want to populate a dropdown box with the DSN last used by the user. However if the DSN has been deleted from the system I just want it to be blank.

Note: deleting the DSN would not be done in the app but rather through the normal control panel (ODBC connections).

Any help is greatly appreciated.

Regards,

Mike
 
I'd say that somewhere you've got a SaveSetting that's saving the server name under the key "DSN Name", instead of the proper key. There's no other way this code could be getting the server name.

Why not clear the registry, run your app once, and then check the DSN Name key? That should verify my guess. Rick Sprague
 
Thanks for your feedback RickSpr. However, perhaps my question was not quite clear. When a user picks a dsn from a drop down list box. If the user succsefully logs in the following event takes place:

SaveSetting App.EXEName, "Options", "DSN Name", "" & cboDSNList.Text & ""

my problem is that if I delete the DSN then go back into the VB app, I get the error described above. I need to trap this error and continue.

Thanks for your time...

Mike
 
I'm confused. Deleting the DSN in the ODBC control panel applet wouldn't eliminate it from the registry, so I'd expect you'd get the name back in GetSetting. And that's what you were saying was happening, right?

That doesn't seem related to getting the 383 error, though. The error occurs on the line "cboDSNList.Text = lastdsn", right? That's what confuses me. A combo box's Text property is certainly not read-only. I could see getting a 2185 error ("You can't reference a property of a control unless it has the focus"), but not a 383. And in any case, none of this has anything to do with whether you've deleted the DSN. Access doesn't have a clue that the text you're trying to put in the combo box is a DSN.

Could the 383 error be happening later, somewhere else? I'm afraid I don't know much about creating an ODBC connection, but I'd think you'd have some kind of problem later, when you try to create a connection using a DSN name that no longer exists.

If I'm not making sense, it would be because I don't know enough about ODBC to respond intelligently. In that case, I apologize for leading you on a wild goose chase. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top