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

rs update not working

Status
Not open for further replies.

tania20

Programmer
Oct 30, 2006
148
AU
Hi, I have tested my databse and everthing works fine but then have given it to a customer and the following part of the code does not seems to be updating as required.

Set rs = db.OpenRecordset("LTOT_second_oxygen2", dbOpenDynaset)
rs.FindFirst "[HospitalNumber] = '" & Me![general_info.HospitalNumber] & "'"
If rs.NoMatch Then
rs.AddNew
rs![HospitalNumber] = Me![general_info.HospitalNumber]
rs.Update
End If

Any ideas why this could be-I am stumped!!!?????
 
is this a split db? does the user at the customer site have relevant network permissions against the back end mdb file?

--------------------
Procrastinate Now!
 
it is not a split database, is only on the local pc.i am totally baffled-can not replicate this on three machines i have tested it on.im just not sure wehre the error lies, with either findfirst, nomatch, addnew or update.all the rest of the database is working fine except for this part
 
could it have something to do with access permissions that may have been set by an IT department when they installed Access?
 
they are not getting any error messages.its simply not adding new record and updating for nomatch
 
I've no idea if this will help but... the form control you're accessing sounds a bit suss to me: Me![general_info.HospitalNumber].

Can you try naming the control and using that, rather than using a field name with the DOT notation? eg, call it 'cboHospitalNumber', and change your code ref to Me!cboHospitalNumber?

Not sure if this will help at all, but may be worth a try.


Max Hugen
Australia
 
i agree the formatting not the greatest, but that doesnt explain why it works with no problems on a range of pcs...of which i have tried in both admin and limited user logins
 
I know, it's maddening when everything works perfectly till the client tries it. If you have access to the client's pc, could you try stepping through the code to ensure you're getting the values you want?

For example, if rs![HospitalNumber] is a required field, and for whatever reason Me![general_info.HospitalNumber] isn't returning a value, the update will fail.

Max Hugen
Australia
 
yeh thats my next step tmrw, but has to be done over phone.for what kind of reasons would it not return a value?
 
At this point I would say it is 50/50 whether this is an actual error, or a user misunderstanding. How much confidence do you have in the person reporting the "error" to you?

If it was me, I would want to look over their shoulder while they do it, or have them send me their database.

When I can't replicate an error myself, and there is no error message, the problem usually turns out to be the operator not understanding the software.

 
G'day JoeAtWork

Yeh, you do have to take users' responses with a grain of salt!

However, I have seen probs that I couldn't replicate in my dev environment... slow network problems, JET versions not current, and so on.

tania20, if you have no way to look over the client's shoulder (the best way, as JoeAtWork suggested), it may not help to get their db, as you may find it just continues to work on your workstation.

One thing you could try is to subscribe to GoToMeeting (but a bit pricey), as this allows you to take control of the user's pc, and try debugging it yourself.

If that's not an option, I'd add some conditional debugging info, eg:

Code:
function myFunc()
...
[b]Const cDEBUG%=True[/b]
Dim iCnt&
...

    Set rs = db.OpenRecordset("LTOT_second_oxygen2", dbOpenDynaset)
    [b]' check that the recordset really did return some records
    if cDEBUG then
        rs.MoveLast: iCnt=rs.RecordCount
        msgbox "Records returned: " & iCnt
    end If

    ' check we have a value
    if cDEBUG then msgbox "Find HospitalNumber: " & _ 
                   Me![general_info.HospitalNumber][/b]

    rs.FindFirst "[HospitalNumber] = '" & _
                 Me![general_info.HospitalNumber] & "'"
    If rs.NoMatch Then

        [b]' see if we had a match
        if cDEBUG then msgbox "No match found"[/b]

        rs.AddNew
        rs![HospitalNumber] = Me![general_info.HospitalNumber]
        rs.Update

        [b]' let's see if a record was added
        if cDEBUG then
            rs.Bookmark = rs.LastModified
            msgbox "Last record added: " & _
                   rs![HospitalNumber]
        endif[/b]
    End If

    ... more code

end function

Using this, you'll only need to ask your user to toggle the const cDEBUG to True, and back to False.

Or you could even temporarily add a checkbox 'cDEBUG' on the form that call the function, and use that to toggle the debugging.

HTH

Max Hugen
Australia
 
You wouldn't happen to have an error logging file the user can send you?

 
hey, thanks to everyone for all their help! the problem is sorted.the database had been saved to all users/application data, so that when the database was opened by a limited user updates and additions via open recordset were not allowed. i solved this by simply moving the folder to the C:/ drive - phew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top