Avatar of SirTKC
SirTKC asked on

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

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

Open in new window

Visual Basic ClassicMicrosoft SQL ServerMicrosoft Access

Avatar of undefined
Last Comment
SirTKC

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
harfang

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
SirTKC

Duh !
I think I have coded too much today...

Thanks a million !!!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck