473,703 Members | 2,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Cannot update, databse or object may be read only"

Hi

I was wondering if anyone could help i have picked this database up
from a
designer who has now left the company. The code is a couple of years
old.

On click of a button it open a recordset which is a query loops until
it
finds the required people and then trys to update one field in the
query. I
then get the error message "Cannot update database or object is read
only".
But this isn't the case.

If i open the query and manually do want the code is trying to do i
works
perfectly and accepts the changes. This problem is driving me bananas
and i
can't fix it.

Would appreciate any help i have posted the code below sorry for the
length.

Private Sub btnAccept_Click ()
On Error GoTo Err_btnAccept_C lick

Dim db As Database
Dim rstProspects As Recordset
Dim HEIGHT_MAX, HEIGHT_MIN As Integer

Dim txtB_Got As Boolean
Dim txtB_Mind As String

DoCmd.Echo False
DoCmd.SetWarnin gs False

DoCmd.OpenQuery "qryDelete_Not_ On_Hold"
DoCmd.OpenQuery "qryNot_On_Hold _1"
DoCmd.OpenQuery "qryNot_On_Hold _2"

DoCmd.SetWarnin gs True
DoCmd.Echo True

Me.Visible = False

If IsNull(txtAGE_M IN) Then

txtAGE_MIN = 18

End If

If IsNull(txtAGE_M AX) Then

txtAGE_MAX = 99

End If

If IsNull(txtHEIGH T_MIN) Then

HEIGHT_MIN = 48
txtHEIGHT_MIN = 48

Else

HEIGHT_MIN = txtHEIGHT_MIN

End If

If IsNull(txtHEIGH T_MAX) Then

HEIGHT_MAX = 99
txtHEIGHT_MAX = 99

Else

HEIGHT_MAX = txtHEIGHT_MAX

End If

If IsNull(txtSINGL E) Then

txtSINGLE = "Don't Care"

End If

If IsNull(txtSEPAR ATED) Then

txtSEPARATED = "Don't Care"

End If

If IsNull(txtDIVOR CED) Then

txtDIVORCED = "Don't Care"

End If

If IsNull(txtWIDOW ED) Then

txtWIDOWED = "Don't Care"

End If

' Matching Process

Set db = CurrentDb()

Set rstProspects = db.OpenRecordse t("qryMembers_M atching")

With rstProspects

.MoveFirst

Do Until .EOF

'If Nz(!OWN_DEPENDA NTS, 0) = 0 Then

'txtB_Got = False

'Else

'txtB_Got = True

'End If

'txtB_Mind = !IDEAL_CHILDREN

If !SEX = txtOpposite_Sex Then

If txtSINGLE = "Don't Care" Or _
(txtSINGLE = "Must be" And !MARITAL_STATUS = "Single")
Or _
(txtSINGLE = "Must not be" And !MARITAL_STATUS <>
"Single")
Then

If txtSEPARATED = "Don't Care" Or _
(txtSEPARATED = "Must be" And !MARITAL_STATUS =
"Separated" )
Or _
(txtSEPARATED = "Must not be" And !MARITAL_STATUS <>
"Separated" ) Then

If txtDIVORCED = "Don't Care" Or _
(txtDIVORCED = "Must be" And !MARITAL_STATUS =
"Divorced") Or _
(txtDIVORCED = "Must not be" And !MARITAL_STATUS <>
"Divorced") Then

If txtWIDOWED = "Don't Care" Or _
(txtWIDOWED = "Must be" And !MARITAL_STATUS = "Widowed")
Or _
(txtWIDOWED = "Must not be" And !MARITAL_STATUS <>
"Widowed")
Then

If !DOB > DateAdd("yyyy", -(txtAGE_MAX + 1), Date) Then
If !DOB <= DateAdd("yyyy", -txtAGE_MIN, Date) Then
If !Total_Height_I nches <= HEIGHT_MAX Then

If !Total_Height_I nches >= HEIGHT_MIN Then

If DCount("[CLIENT_A]", "MATCH_HISTORY" , _
"[CLIENT_A] = " & txtINTRO_OCC_NO & " AND " & _
"[CLIENT_B] = " & !MEMBER_NO) = 0 Then
If DCount("[CLIENT_A]", "qryAll_B_Match ed", _
"[CLIENT_B] = " & txtINTRO_OCC_NO & " AND " & _
"[CLIENT_A] = " & !MEMBER_NO) = 0 Then

If (txtA_Smoker = False And !SMOKER = False) Or _
(txtA_Smoker = True And !IDEAL_SMOKING <> "Never") Or _
(txtA_Ideal_Smo ker = True And !SMOKER = False) Or _
(txtA_Ideal_Smo ker = False And !SMOKER = True) Then

If (txtA_Got = False And txtA_Mind <> "Yes") Or _
(Nz(!OWN_DEPEND ANTS, 0) = 0 And !IDEAL_CHILDREN <>
"Yes") Or _
(txtA_Got = False And txtA_Mind = "Yes" And _
Nz(!OWN_DEPENDA NTS, 0) = 0 And !IDEAL_CHILDREN = "Yes")
Or _
(txtA_Got = True And txtA_Mind = "No" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN = "No")
Or _
(txtA_Got = True And txtA_Mind = "Maybe" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN =
"Maybe") Or _
(txtA_Got = True And txtA_Mind = "Maybe" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN = "No")
Or _
(Nz(!OWN_DEPEND ANTS, 0) > 0 And !IDEAL_CHILDREN =
"Maybe" And _
txtA_Got = True And txtA_Mind = "No") Then

.Edit

!PICKED = True

.Update

End If ' Children

End If ' Smoker

End If ' Client B No Match

End If ' Client A No Match

End If ' Minimum Height

End If ' Maximum Height

End If ' Minimum Age

End If ' Maximum Age

End If ' Widowed

End If ' Divorced

End If ' Separated

End If ' Single

End If ' Opposite sex

.MoveNext

Loop

.Close

End With

Forms!frmIntrod uctions!fsubMat ching_Prospects .Requery
Forms!frmIntrod uctions!pgProsp ects.SetFocus

Exit_btnAccept_ Click:
Exit Sub

Err_btnAccept_C lick:
MsgBox Err.DESCRIPTION
Resume Exit_btnAccept_ Click

End Sub

Thanks

Gillian

Apr 10 '06 #1
1 2059
Br
So what line does the error occur on???

I assume the .update ?

Perhaps try....

Set rstProspects = db.OpenRecordse t("qryMembers_M atching", dbOpenDynaset)

It sounds like your recordset is not updateable.

Or is it happening when calling one of the other queries?

Gilz wrote:
Hi

I was wondering if anyone could help i have picked this database up
from a
designer who has now left the company. The code is a couple of years
old.

On click of a button it open a recordset which is a query loops until
it
finds the required people and then trys to update one field in the
query. I
then get the error message "Cannot update database or object is read
only".
But this isn't the case.

If i open the query and manually do want the code is trying to do i
works
perfectly and accepts the changes. This problem is driving me bananas
and i
can't fix it.

Would appreciate any help i have posted the code below sorry for the
length.

Private Sub btnAccept_Click ()
On Error GoTo Err_btnAccept_C lick

Dim db As Database
Dim rstProspects As Recordset
Dim HEIGHT_MAX, HEIGHT_MIN As Integer

Dim txtB_Got As Boolean
Dim txtB_Mind As String

DoCmd.Echo False
DoCmd.SetWarnin gs False

DoCmd.OpenQuery "qryDelete_Not_ On_Hold"
DoCmd.OpenQuery "qryNot_On_Hold _1"
DoCmd.OpenQuery "qryNot_On_Hold _2"

DoCmd.SetWarnin gs True
DoCmd.Echo True

Me.Visible = False

If IsNull(txtAGE_M IN) Then

txtAGE_MIN = 18

End If

If IsNull(txtAGE_M AX) Then

txtAGE_MAX = 99

End If

If IsNull(txtHEIGH T_MIN) Then

HEIGHT_MIN = 48
txtHEIGHT_MIN = 48

Else

HEIGHT_MIN = txtHEIGHT_MIN

End If

If IsNull(txtHEIGH T_MAX) Then

HEIGHT_MAX = 99
txtHEIGHT_MAX = 99

Else

HEIGHT_MAX = txtHEIGHT_MAX

End If

If IsNull(txtSINGL E) Then

txtSINGLE = "Don't Care"

End If

If IsNull(txtSEPAR ATED) Then

txtSEPARATED = "Don't Care"

End If

If IsNull(txtDIVOR CED) Then

txtDIVORCED = "Don't Care"

End If

If IsNull(txtWIDOW ED) Then

txtWIDOWED = "Don't Care"

End If

' Matching Process

Set db = CurrentDb()

Set rstProspects = db.OpenRecordse t("qryMembers_M atching")

With rstProspects

.MoveFirst

Do Until .EOF

'If Nz(!OWN_DEPENDA NTS, 0) = 0 Then

'txtB_Got = False

'Else

'txtB_Got = True

'End If

'txtB_Mind = !IDEAL_CHILDREN

If !SEX = txtOpposite_Sex Then

If txtSINGLE = "Don't Care" Or _
(txtSINGLE = "Must be" And !MARITAL_STATUS = "Single")
Or _
(txtSINGLE = "Must not be" And !MARITAL_STATUS <>
"Single")
Then

If txtSEPARATED = "Don't Care" Or _
(txtSEPARATED = "Must be" And !MARITAL_STATUS =
"Separated" )
Or _
(txtSEPARATED = "Must not be" And !MARITAL_STATUS <>
"Separated" ) Then

If txtDIVORCED = "Don't Care" Or _
(txtDIVORCED = "Must be" And !MARITAL_STATUS =
"Divorced") Or _
(txtDIVORCED = "Must not be" And !MARITAL_STATUS <>
"Divorced") Then

If txtWIDOWED = "Don't Care" Or _
(txtWIDOWED = "Must be" And !MARITAL_STATUS = "Widowed")
Or _
(txtWIDOWED = "Must not be" And !MARITAL_STATUS <>
"Widowed")
Then

If !DOB > DateAdd("yyyy", -(txtAGE_MAX + 1), Date) Then
If !DOB <= DateAdd("yyyy", -txtAGE_MIN, Date) Then
If !Total_Height_I nches <= HEIGHT_MAX Then

If !Total_Height_I nches >= HEIGHT_MIN Then

If DCount("[CLIENT_A]", "MATCH_HISTORY" , _
"[CLIENT_A] = " & txtINTRO_OCC_NO & " AND " & _
"[CLIENT_B] = " & !MEMBER_NO) = 0 Then
If DCount("[CLIENT_A]", "qryAll_B_Match ed", _
"[CLIENT_B] = " & txtINTRO_OCC_NO & " AND " & _
"[CLIENT_A] = " & !MEMBER_NO) = 0 Then

If (txtA_Smoker = False And !SMOKER = False) Or _
(txtA_Smoker = True And !IDEAL_SMOKING <> "Never") Or _
(txtA_Ideal_Smo ker = True And !SMOKER = False) Or _
(txtA_Ideal_Smo ker = False And !SMOKER = True) Then

If (txtA_Got = False And txtA_Mind <> "Yes") Or _
(Nz(!OWN_DEPEND ANTS, 0) = 0 And !IDEAL_CHILDREN <>
"Yes") Or _
(txtA_Got = False And txtA_Mind = "Yes" And _
Nz(!OWN_DEPENDA NTS, 0) = 0 And !IDEAL_CHILDREN = "Yes")
Or _
(txtA_Got = True And txtA_Mind = "No" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN = "No")
Or _
(txtA_Got = True And txtA_Mind = "Maybe" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN =
"Maybe") Or _
(txtA_Got = True And txtA_Mind = "Maybe" And _
Nz(!OWN_DEPENDA NTS, 0) > 0 And !IDEAL_CHILDREN = "No")
Or _
(Nz(!OWN_DEPEND ANTS, 0) > 0 And !IDEAL_CHILDREN =
"Maybe" And _
txtA_Got = True And txtA_Mind = "No") Then

.Edit

!PICKED = True

.Update

End If ' Children

End If ' Smoker

End If ' Client B No Match

End If ' Client A No Match

End If ' Minimum Height

End If ' Maximum Height

End If ' Minimum Age

End If ' Maximum Age

End If ' Widowed

End If ' Divorced

End If ' Separated

End If ' Single

End If ' Opposite sex

.MoveNext

Loop

.Close

End With

Forms!frmIntrod uctions!fsubMat ching_Prospects .Requery
Forms!frmIntrod uctions!pgProsp ects.SetFocus

Exit_btnAccept_ Click:
Exit Sub

Err_btnAccept_C lick:
MsgBox Err.DESCRIPTION
Resume Exit_btnAccept_ Click

End Sub

Thanks

Gillian


--
regards,

Br@dley
Apr 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3960
by: Fie Fie Niles | last post by:
I have IIS installed on XP Professional workstation machine. I have an ASP page that open connection to an Access database, then when trying to update the database, it gave me the error "cannot update database or object is read-only". This is a workstation machine, not connected to any other computer, and I login to the PC using an administrator account. I already check the .MDB file is NOT read-only. But, I do not see the .LDB file....
10
3716
by: mike | last post by:
regards: I use Jtidy (api) to translate a HTML file into a "XHTML file". But The "XHTML file" cannot be identified by nokia 6600. Do I miss something important? Or this is Jtidy's weakness or bug? Can someone excellent to tell me the reason. best wishes
7
22741
by: Ryan Park | last post by:
Hi, //SITUATION I got a panel control that hold a certain position on a form. Every controls or UIs are on this panel. At certain situation, I called dispose() method of this panel control and change it with other panel which contains other business logic and UI controls.
3
9578
by: Justin To via AccessMonster.com | last post by:
I just distributed a FE mde file throught my department, and while stress testing on the performance of the new release, 3 users got the following error: The instruction at ... referenced memory at ... The memory cannot be "read". this seems like a computer-local problem as I cannot reproduce the same error on any other computers I tried running Dr. Watson (win2k) and it says "Exception number: c0000005
4
2065
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone know why? thx
3
4930
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that is being sent to the database is correct and the changes are eventually being made. If I refresh the page after the update then the new values appear. I noticed that when I put a breakpoint in my update handler everything works fine. When I take...
6
10676
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the data on the datasource. It simply gets the first name and last name of an instructor and displays it in the grid. I have two major problems.... One, it doesn't display in the column until the row is saved, (Even after calling a refresh on the...
0
2064
by: mvdkwong | last post by:
I am trying to run a macro that will export a table into a fixed length file (see below). However, when I run it, I get the following error: "Cannot update. Database or object is read-only." I've tried a few things that I found in postings, but I'm not getting anywhere. Please advise on what I can do. '------------------------------------------------------------ ' mcr_Export_Test '
1
6107
by: marknewbery | last post by:
Hi, I have been trying to get a php, mySQL install to work and talk together on Windows XP SP2 with IIS. So far I installed and received a responce from php(V5 - manual install) though the <?php phpinfo(); ?> command which prints out the current settings of the php install. I then installed mySQL complete setup (V5) and ran the server instance
0
8744
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9240
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7846
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5920
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2055
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.