Problem with populating a textbox

avtuvy

Registered User.
Local time
Today, 13:35
Joined
Jan 10, 2010
Messages
39
I need to populate a textbox with some data after a selection is done in a combo box, I get an error when I try to enter eny data into the text box. the code below is a test code which gives the error.

Code:
Private Sub cmbServerName_AfterUpdate()

txtSerialNumber.Value = "5"
End Sub

The error is: Run -time error 2448
You can't assign a value to this object

Please help.
 
What version of Access are you running? Is txtSerialNumber the name of a control or a field or both? If it is a control, can you put values in it from the keyboard?
 
I am using Access 2007 and txtSerialNumber is a text box control. I am not sure what you mean by "can you put values in it from the keyboard?" I tried to type data into the text box from the keyboard and I am not able to do that.

Maybe I can get two for the price of one, I am using that Access form to display data stored in a SQL 2005 database and I would like to use some of the stored procedures of that database. I looked for tutorial which explains how to do that and cannot find anything, if you know of any site which has that info please send me a link.

Thank you for the quick response
 
The error you are getting is because your RecordSource is not updateable, which is what I suspected and the reason for the keyboard question. This link might help you resolve your issue. As for SQL Server, my knowledge is almost nil, sorry.
 
The VBA code that I am using does not even access the database, it attempt to write a hard coded string into the text box, I suspect that it has to do with a property of the text box but I do not know which one it is.
 
What is the ControlSource of the txtSerialNumber control?
 
Eureka, that was the problem, control source was set to a constant. Thank you for your help
 
One last thing, I run a query in my VBA code and it returns a single value, how can i assign this value to a string?

resultString=DoCmd.OpenQuery "qrySerialNumber"
 
Yes I can I ma going to try it in a few minutes, is it going to work for more complicated queries which involve more that on table?
 
Depends. Can you join those tables in a query? The Domain Functions work just fine on queries.
 
In that case the Domain Functions should work just fine for you.
 

Users who are viewing this thread

Back
Top Bottom