Apologies for the 'future' post - Code Wizard needed

  • Thread starter Thread starter Henro
  • Start date Start date
H

Henro

Can anyone tell me why in the following code only the begindate (dtWhen) is
added?

Private Sub Form_AfterInsert()

With Me.RecordsetClone

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = Me.Omschrijving
![Relatie] = Me.Relatie
![Omschrijving] = Me.Omschrijving
![2e Engineer] = Me.Ctl2e_Engineer
![Engineer] = Me.Engineer
![AgendaItem] = Me.AgendaItem
![Einddatum] = Me.Einddatum
![Begindatum] = dtwhen
.Update
Next
End With
End Sub

TIA Henro
 
I believe it's because Me.Omschrigving, Me.Relatie, etc. all refer to the
value of the current row in the recordset (which doesn't have a value yet)

If you're trying to refer to values in controls on the form, rename the
controls so that their names are the same as the fields to which they're
bound.

If you're trying to refer to values of a particular row in the recordset,
store those values in variables, and use the variables to assign the values.
 
Try:

Dim txtOmschrijving As String
Dim txtRelatie As String
Dim txt2e Engineer As String
Dim txtEngineer As String
Dim txtAgendaItem As String
Dim txtEinddatum As String

With Me.RecordsetClone

txtOmschrijving = Me.Omschrijving
txtRelatie = Me.Relatie
txt2e Engineer = Me.Ctl2e_Engineer
txtEngineer = Me.Engineer
txtAgendaItem = Me.AgendaItem
txtEinddatum = Me.Einddatum

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = txtOmschrijving
![Relatie] = txtRelatie
![2e Engineer] = txtCtl2e_Engineer
![Engineer] = txtEngineer
![AgendaItem] = txtAgendaItem
![Einddatum] = txtEinddatum
![Begindatum] = dtwhen
.Update
Next
End With


(Change the variable types as appropriate)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Henro said:
Isn't that why I use the recordsetclone?

I changed the me. thingies in thingie without the me., tried even
forms!name_form!Name_control but it still doesn't fill anything. Declaring
them as variables didn't help either :-(

Douglas J. Steele said:
I believe it's because Me.Omschrigving, Me.Relatie, etc. all refer to the
value of the current row in the recordset (which doesn't have a value yet)

If you're trying to refer to values in controls on the form, rename the
controls so that their names are the same as the fields to which they're
bound.

If you're trying to refer to values of a particular row in the recordset,
store those values in variables, and use the variables to assign the values.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Henro said:
Can anyone tell me why in the following code only the begindate
(dtWhen)
is
added?

Private Sub Form_AfterInsert()

With Me.RecordsetClone

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = Me.Omschrijving
![Relatie] = Me.Relatie
![Omschrijving] = Me.Omschrijving
![2e Engineer] = Me.Ctl2e_Engineer
![Engineer] = Me.Engineer
![AgendaItem] = Me.AgendaItem
![Einddatum] = Me.Einddatum
![Begindatum] = dtwhen
.Update
Next
End With
End Sub

TIA Henro
 
Got it working, thnx!

Henro

Douglas J. Steele said:
Try:

Dim txtOmschrijving As String
Dim txtRelatie As String
Dim txt2e Engineer As String
Dim txtEngineer As String
Dim txtAgendaItem As String
Dim txtEinddatum As String

With Me.RecordsetClone

txtOmschrijving = Me.Omschrijving
txtRelatie = Me.Relatie
txt2e Engineer = Me.Ctl2e_Engineer
txtEngineer = Me.Engineer
txtAgendaItem = Me.AgendaItem
txtEinddatum = Me.Einddatum

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = txtOmschrijving
![Relatie] = txtRelatie
![2e Engineer] = txtCtl2e_Engineer
![Engineer] = txtEngineer
![AgendaItem] = txtAgendaItem
![Einddatum] = txtEinddatum
![Begindatum] = dtwhen
.Update
Next
End With


(Change the variable types as appropriate)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Henro said:
Isn't that why I use the recordsetclone?

I changed the me. thingies in thingie without the me., tried even
forms!name_form!Name_control but it still doesn't fill anything. Declaring
them as variables didn't help either :-(

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> schreef in bericht
I believe it's because Me.Omschrigving, Me.Relatie, etc. all refer to the
value of the current row in the recordset (which doesn't have a value yet)

If you're trying to refer to values in controls on the form, rename the
controls so that their names are the same as the fields to which they're
bound.

If you're trying to refer to values of a particular row in the recordset,
store those values in variables, and use the variables to assign the values.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Can anyone tell me why in the following code only the begindate (dtWhen)
is
added?

Private Sub Form_AfterInsert()

With Me.RecordsetClone

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = Me.Omschrijving
![Relatie] = Me.Relatie
![Omschrijving] = Me.Omschrijving
![2e Engineer] = Me.Ctl2e_Engineer
![Engineer] = Me.Engineer
![AgendaItem] = Me.AgendaItem
![Einddatum] = Me.Einddatum
![Begindatum] = dtwhen
.Update
Next
End With
End Sub

TIA Henro
 
Isn't that why I use the recordsetclone?

I changed the me. thingies in thingie without the me., tried even
forms!name_form!Name_control but it still doesn't fill anything. Declaring
them as variables didn't help either :-(

Douglas J. Steele said:
I believe it's because Me.Omschrigving, Me.Relatie, etc. all refer to the
value of the current row in the recordset (which doesn't have a value yet)

If you're trying to refer to values in controls on the form, rename the
controls so that their names are the same as the fields to which they're
bound.

If you're trying to refer to values of a particular row in the recordset,
store those values in variables, and use the variables to assign the values.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Henro said:
Can anyone tell me why in the following code only the begindate (dtWhen) is
added?

Private Sub Form_AfterInsert()

With Me.RecordsetClone

For dtwhen = Me.Begindatum + 1 To Me.Einddatum
.AddNew
![Omschrijving] = Me.Omschrijving
![Relatie] = Me.Relatie
![Omschrijving] = Me.Omschrijving
![2e Engineer] = Me.Ctl2e_Engineer
![Engineer] = Me.Engineer
![AgendaItem] = Me.AgendaItem
![Einddatum] = Me.Einddatum
![Begindatum] = dtwhen
.Update
Next
End With
End Sub

TIA Henro
 
Back
Top