troubleshooting Question

MS ACCESS 2007 - "You Can't save this record at this time"

Avatar of SirTKC
SirTKC asked on
Microsoft AccessMicrosoft SQL ServerVisual Basic Classic
2 Comments1 Solution876 ViewsLast Modified:
Hi again :-)

Now here is where I am trapped...

I have the code below that works well excepted that when I try to close my form, I get an error message saying: "You Can't save this record at this time"
I do know that it has something to do with my RecordSet not properly set, because it started to appear as soon as I added it.

My goal is very simple, I need to use one variable located in another table in order to complete the calculation. See "SELECT"

Is there a better way to achive this & (more simple - no mistake) ?

I did try my best ;-/


Private Sub Form_AfterUpdate()
On Error GoTo Err_Handler
            
Dim TheBox As String
Dim x As Integer
Dim y As Integer
Dim z As Integer
 
Dim RS As DAO.Recordset
Dim strSQL As String
 
strSQL = "SELECT DesignMaterials.M_Name, DesignMaterials.M_Poid " & _
         "FROM DesignMaterials " & _
         "WHERE (((DesignMaterials.M_Name)= '" & Me.D_Mat & "' ));"
            
 
Set RS = CurrentDb.OpenRecordset(strSQL)
 
TheBox = Me.Box_Name.Value
x = Me.D_Long.Value
y = Me.D_Larg.Value
z = Me.D_Haut.Value
 
Select Case TheBox
Case "Filler"
Me.EmbPoids.Value = (((x * y * 2) + (z * y * 2)) / 144) * RS!M_Poid
Case "Régulière"
Me.EmbPoids.Value = (((x * y * 2) + (z * y * 2) + (((x / 2) * z) * 4) + (((z / 2) * x) * 4)) / 144) * RS!M_Poid
Case "Semi-régulière"
Me.EmbPoids.Value = (((x * y * 2) + (z * y * 2) + (((x / 2) * z) * 2) + (((z / 2) * x) * 2)) / 144) * RS!M_Poid
End Select
 
RS.Close
Set RS = Nothing
 
 
Exit_Handler:
    Exit Sub
 
Err_Handler:
    MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
    Resume Exit_Handler
    
 
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros