Quantcast
Channel: Access for Developers forum
Viewing all articles
Browse latest Browse all 14673

VBA update multivalue fields

$
0
0

Hi I am trying to update a main table (Passport) containing a list of servers:

The Issues field is a multivalue lookup from the issues table. I have a table "Serversdown" copied from an excel report and want to update the issues in the passport table so that Issue ID 1, Server down, is checked for the corresponding records. I have tried with a query update and cannot get it to work:

UPDATE Passport INNER JOIN Serversdown ON Passport.Hostname = Serversdown.Hostname SET Passport.Issues.[Value] = 1;

I have also tried to use a form that selects only the corresponding servers and the issues field and attempted to use vba to update with a nested loop but cant get it to work. The form is based on this query:

SELECT Passport.ID, Passport.Issues, Passport.Issues.Value
FROM Server INNER JOIN Passport ON Server.Hostname = Passport.Hostname;

This is the vba code:

Dim rst As Recordset
Dim db As Database
Dim childRs As Recordset
Set db = CurrentDb()
Set rst = Forms!Form3.RecordsetClone

'Loop through the recordset
Do While Not rst.EOF
    Set childRs = rst.Fields("Issues").Value
    rst.Edit
        Do While Not childRs.EOF
            childRs.Edit
            childRs.Fields(0).Value = 33
            childRs.Update
        childRs.MoveNext
        Loop
    rst.Update
    rst.MoveNext
Loop

'Close and Destroy recordset
rst.Close
childRs.Close

Set childRs = Nothing
Set rst = Nothing
Set conn = Nothing

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, vbCritical
Resume Proc_Exit

Is there a way to do this?



Viewing all articles
Browse latest Browse all 14673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>