Re: Carry data over to new record...



Ok, that's better. Does your event procedure look like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Call CarryOver(Me)
End Sub

And are the names of your textboxes exactly the same as the fields they are
bound to?

It's not clear if the function is getting called at all (being able to go to
a new record with the record selector isnt proof), so you could put this
line:
msgbox "Carry Over was called"
after the dim statements in the CarryOver procedure to make sure it got
called.

hope this helps
-John

<campbellbrian2001@xxxxxxxxx> wrote in message
news:1135978433.274746.62200@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Sorry!
> Here's what I did..
> Open a new form in Design View with 4 text boxes bound to 4 fields in a
> table.
> In the Properties Box, selected the BeforeInsert event, and typed in
> [Event Procedure]
> "Call CarryOver(Me)"
> Created a module "basCarryOver" and typed this 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 DAO.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:
> Set rst = Nothing
> 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 "Carry-over values were not assigned, from " & ctl.Name
> & _
> ". Error #" & Err.Number & ": " & Err.Description,
> vbExclamation, "CarryOver()"
> Resume Exit_CarryOver
> End Select
> End Sub
>
>
> The record selector gives a new record but without the text boxes
> pre-filled with the last record's values.
>
> Thanks! Brian
>


.



Relevant Pages

  • RE: Text box validation
    ... Server 2000 with ADO to populate the txtCurrent_user box as follows. ... Private Sub Form_Open ... Dim rsLOGIN_ID As Recordset ... eventhough both boxes have the ...
    (microsoft.public.access.formscoding)
  • Re: Default value in form
    ... unbound text boxes. ... >Private Sub txtName_AfterUpdate ... >> Dim varTrack As String ... >> Private Function LastTrackAs String ...
    (microsoft.public.access.formscoding)
  • Re: something with "IF"
    ... The first and second text boxes have code in the after update event. ... Private Sub tbFirst_AfterUpdate ... Dim r As DAO.Recordset ... ' might need more limits if recordset returns ...
    (microsoft.public.access.modulesdaovba)
  • Re: something with "IF"
    ... "Steve Sanford": ... The first and second text boxes have code in the after update event. ... Private Sub tbFirst_AfterUpdate ... Dim r As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: How can a Combobox option, the one which is the default selected change based on todays date?
    ... :I have 3 combo boxes inside the html page where in I take the year ... So when he opens the page the combo boxes should display 13 September ... Sub Window_Onload ... Dim Length ...
    (microsoft.public.scripting.vbscript)