Runtime Error 2448

G

Guest

I am trying to write a an Afterupdate Sub that takes a person's age and
gender and goes to the table PushUps and gets the correct score based on the
number of pushups compelted, age and gender and writes it to the record.
When I changed the variable myPUScore to the following
Forms!APFT_Main!PUScore I get the run time error 2448: You can't assign a
value to this object.

The variable myPUScore is how I was testing the DLookup to make sure it was
retrieving the correct value.

Private Sub PURaw_AfterUpdate()

Dim myGender As String
Dim myAge As Integer
Dim myPUScore As Integer

myGender = DLookup("[APFTFormQuery]![Gender]", "[APFTFormQuery]",
"[AlphaRosterID] = " & Forms!APFT_Main!AlphaRosterID)
myAge = DLookup("[APFTFormQuery]![Age]", "[APFTFormQuery]", "[AlphaRosterID]
= " & Forms!APFT_Main!AlphaRosterID)

If myGender = "Male" Then
If myAge <= 21 Then
Forms!APFT_Main!PUScore = DLookup("[PushUp]![Group 1M]", "[PushUp]",
"[PushupID]= " & Forms!APFT_Main!PURaw)

'The Else statement checks for the age of the female and runs the
appropriate DLookUp
Else
If myAge <= 21 Then
myPUScore = DLookup("[PushUp]![Group 1F]", "[PushUp]", "[PushupID]= " &
Forms!APFT_Main!PURaw)
End Sub
 
G

Guest

After much poking and prodding and searching the site I found this solution:

Forms!APFTMainform.APFTSubform!PUScore = Dlookup(...)is required to write to
the control in the subform and now the code works as desired.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top