Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suffering Oxygen Deprivation when using Access!

Status
Not open for further replies.

FBM357

MIS
Jun 2, 2003
77
US
I'm encountering a headache inheriting this project from someone. First of all, I had to convert it from 97 -> 2000. Needless to say, things went rather easy BUT....I'm now receiving and error when using the following: "Call CarryOver(Me)". Am I missing something? Is there an alternative method for this?

I've no more hair on the top of my head to pull, so other areas may soon suffer until I get a better understanding of this... LOL.

Any help would be greatly appreciated.

FBM

"If you want SQUARE work, you DON'T cut CORNERS!!!" ... :)
 
What error are you getting, and what the Sub Definition look like for CarryOver

Sub CarryOver (???????).

The key is knowing whether CarryOver is expecting an object reference, or the name of the Object.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Okay, here is the code...

Sub CarryOver(frm As Form)
On Error GoTo Err_CarryOver
' Purpose: Carry the values over from the last record to a new one.
' Usage: In a form's BeforeInsert event procedure, enter:
' Call CarryOver(Me)
' Notes: This example limited to text boxes and combo boxes.
' Text/combo boxes must have same Name as the fields they represent.

Dim rst As Recordset
Dim ctl As Control
Dim i As Integer

Set rst = frm.RecordsetClone
If rst.RecordCount > 0 Then
rst.MoveLast
For i = 0 To frm.Count - 1
Set ctl = frm(i)
If TypeOf ctl Is TextBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
ElseIf TypeOf ctl Is ComboBox Then
If Not IsNull(rst(ctl.Name)) Then
ctl = rst(ctl.Name)
End If
End If
Next
End If

Exit_CarryOver:
On Error Resume Next
rst.Close
On Error GoTo 0
Exit Sub

Err_CarryOver:
Select Case Err
Case 2448 'Cannot assign a value
Debug.Print "Value cannot be assigned to " & ctl.Name
Resume Next
Case 3265 'Name not found in this collection.
Debug.Print "No matching field name found for " & ctl.Name
Resume Next
Case Else
MsgBox "A critical error has occurred, vbMsgBoxStyle=vbOKOnly" '"Carry-over values were not assigned, from " & ctl.NAME & ". Error #" & Err & ": " & Error$, 48, "CarryOver()"
Resume Exit_CarryOver
End Select
End Sub



"If you want SQUARE work, you DON'T cut CORNERS!!!" ... :)
 
How about what is the error, and on which line does it occur?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
as for the error...

Compile Error:

Ambiguous Name Detected: CarryOver

"If you want SQUARE work, you DON'T cut CORNERS!!!" ... :)
 
the above error occurs when the program tries to perform ... "Call CarryOver(Me)

"If you want SQUARE work, you DON'T cut CORNERS!!!" ... :)
 
Error said:
Ambiguous Name Detected
Either the sub is defined twice, or you are using the name CarryOver for something else besides this subroutine in the application.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Cajun,

You were exactly correct! A function with the same name (though saved under another name) was causing the problem.

Thanks.

*sigh* ... now I can allow the hair to regrow barring I find any other *gulp* simple problems... :p

FBM

"If you want SQUARE work, you DON'T cut CORNERS!!!" ... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top