Apologies for the 'future' post - Code Wizard needed

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
 
D

Douglas J. Steele

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.
 
D

Douglas J. Steele

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
 
H

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
 
H

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
 

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

Similar Threads

Put SQL query in VBA? 3
variable in stringquery? 2

Top