• 2013 - Seek/FindFirst/FindNext record then update

    From noodnutt@21:1/5 to All on Tue Sep 1 23:17:17 2020
    Hi Team

    I haven't done much record finding/updating in the past as most DB's I have built have been purely for data storage input/output.

    I have trawled google for examples, but have yet to find anything I that fits my requirement.

    Essentially I have a nice bit of code that creates and sends an email.

    txfFleetNo is an unbound control which resides in the Header of the sfrm_30_E. I pass it's value from a cmdBtn based on the record in the detail section of a continuous form.

    Once the email code runs though, I would like to open a table and update a field with a numeric value.

    BTW: the continuous form is based on a query. I know it is update-able given it has already update the first record, albeit not quite as I expected.

    I know the following syntax is totally wrong, but it's the best way for me to explain it:

    As always, heaps of thanks in advance for any assistance.

    Cheers
    Mark.

    Table: tblConEqReg
    Field: txfConFleetNo = Text
    Field: lnfOutcome = Long

    Form: sfrm_30_E
    Control: txfFleetNo

    OpenRecordset = tblConEqReg
    Where txfConFleetNo = txfFleetNo
    If isNull(lnfOutcome) then
    lnfOutcome = 1 'Pending
    Update
    End if

    Once the user gets a reply email for the one he/she has sent then they open frmPending_E. I tried a code I found in one of the groups on google but it only ever update the first record in the table and did some unwanted changes to the txfConFleetNo field
    I wasn't expecting, hence the reason I am here looking for help.

    Table: tblConEqReg
    Field: txfConFleetNo = Text
    Field: lnfOutcome = Long

    Form: frmPending_E
    Control: txfFleetNo

    OpenRecordset = tblConEqReg
    Where txfConFleetNo = txfFleetNo
    If lnfOutcome = 1 then
    lnfOutcome = 2 'Completed
    Update
    End if

    This is the code I used to limited unexpected result.

    Set db = CurrentDb
    Set rec = db.OpenRecordset("Select * from tblConEqReg")
    rec.Edit
    rec("txfConFleetNo") = Me.txfFleetNo
    rec("lnfOutcome") = 1
    rec.Update
    rec.Close
    Set rec = Nothing
    Set db = Nothing

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From noodnutt@21:1/5 to All on Wed Sep 2 23:55:39 2020
    Hi All

    Disregard. I managed to find my very old Access 97 Developers Handbook, and although very much out of date, it had some handy examples that got me where I needed to be.

    Cheers
    Mark.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)