PC Review


Reply
Thread Tools Rate Thread

Differentiate Between Variables!!

 
 
=?Utf-8?B?a2VubnlrZWU=?=
Guest
Posts: n/a
 
      6th Jun 2005
Hi all.

The following code is from "Transportation For Data !!" post and from a
professional David C. Holley.

Sub AddClientsToTransfer()
Dim targetRecordSet As DAO.Recordset
Dim sourceRecordset As DAO.Recordset
'Grab the records to copy
Set sourceRecordset = Me.RecordsetClone
'Open up the table that the records will be added to
Set targetRecordSet = CurrentDb.OpenRecordset("tblTransferGuests")
'Loop through the records to be copied and copy them to the table
While Not sourceRecordset.EOF
targetRecordSet.AddNew
targetRecordSet("lngTransportId") = sourceRecordset("lngTransportID")
targetRecordSet("txtAirline") = sourceRecordset("cboAirlineDefault")
targetRecordSet("txtFlightNumber") = sourceRecordset("txtFlightNumberDefault")
targetRecordSet("dteFlightTime") = sourceRecordset("dteFlightTimeDefault")
targetRecordSet("txtCity") = sourceRecordset("txtCityDefault")
targetRecordSet("lngClientId") = sourceRecordset("lngClientId")
targetRecordSet.Update
sourceRecordset.MoveNext
Wend
Set targetRecordSet = Nothing
Set sourceRecordset = Nothing
Me.Requery
End Sub

Can anyone explain to me which one is the variable (text box) and where to
put these code and do i need any module added before it?

For further information please look at my last post on "Transportation For
Data !!"

Thanks in advance.

Kennykee (newbie in VBA)
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGVycnk=?=
Guest
Posts: n/a
 
      9th Jun 2005
Hello Kenny
Where you put that code snippet depends on where it is going to be used from.
If it will be used from multiple forms or other calls put it in a module,
otherwise put it in the form where it is to be used.
To put it in a module change the 'Sub ClientsToTransfer()' to Public Sub
ClientsToTransfer(). To put it in a form change it to 'Private Sub
ClientsToAdd()

To ativate the Sub put a button on the form and in the Click event of the
button put ClientsToTransfer
HTH
Terry
You cal

"kennykee" wrote:

> Hi all.
>
> The following code is from "Transportation For Data !!" post and from a
> professional David C. Holley.
>
> Sub AddClientsToTransfer()
> Dim targetRecordSet As DAO.Recordset
> Dim sourceRecordset As DAO.Recordset
> 'Grab the records to copy
> Set sourceRecordset = Me.RecordsetClone
> 'Open up the table that the records will be added to
> Set targetRecordSet = CurrentDb.OpenRecordset("tblTransferGuests")
> 'Loop through the records to be copied and copy them to the table
> While Not sourceRecordset.EOF
> targetRecordSet.AddNew
> targetRecordSet("lngTransportId") = sourceRecordset("lngTransportID")
> targetRecordSet("txtAirline") = sourceRecordset("cboAirlineDefault")
> targetRecordSet("txtFlightNumber") = sourceRecordset("txtFlightNumberDefault")
> targetRecordSet("dteFlightTime") = sourceRecordset("dteFlightTimeDefault")
> targetRecordSet("txtCity") = sourceRecordset("txtCityDefault")
> targetRecordSet("lngClientId") = sourceRecordset("lngClientId")
> targetRecordSet.Update
> sourceRecordset.MoveNext
> Wend
> Set targetRecordSet = Nothing
> Set sourceRecordset = Nothing
> Me.Requery
> End Sub
>
> Can anyone explain to me which one is the variable (text box) and where to
> put these code and do i need any module added before it?
>
> For further information please look at my last post on "Transportation For
> Data !!"
>
> Thanks in advance.
>
> Kennykee (newbie in VBA)

 
Reply With Quote
 
=?Utf-8?B?a2VubnlrZWU=?=
Guest
Posts: n/a
 
      9th Jun 2005
Thanks Terry, I will try it out first.

"Terry" wrote:

> Hello Kenny
> Where you put that code snippet depends on where it is going to be used from.
> If it will be used from multiple forms or other calls put it in a module,
> otherwise put it in the form where it is to be used.
> To put it in a module change the 'Sub ClientsToTransfer()' to Public Sub
> ClientsToTransfer(). To put it in a form change it to 'Private Sub
> ClientsToAdd()
>
> To ativate the Sub put a button on the form and in the Click event of the
> button put ClientsToTransfer
> HTH
> Terry
> You cal
>
> "kennykee" wrote:
>
> > Hi all.
> >
> > The following code is from "Transportation For Data !!" post and from a
> > professional David C. Holley.
> >
> > Sub AddClientsToTransfer()
> > Dim targetRecordSet As DAO.Recordset
> > Dim sourceRecordset As DAO.Recordset
> > 'Grab the records to copy
> > Set sourceRecordset = Me.RecordsetClone
> > 'Open up the table that the records will be added to
> > Set targetRecordSet = CurrentDb.OpenRecordset("tblTransferGuests")
> > 'Loop through the records to be copied and copy them to the table
> > While Not sourceRecordset.EOF
> > targetRecordSet.AddNew
> > targetRecordSet("lngTransportId") = sourceRecordset("lngTransportID")
> > targetRecordSet("txtAirline") = sourceRecordset("cboAirlineDefault")
> > targetRecordSet("txtFlightNumber") = sourceRecordset("txtFlightNumberDefault")
> > targetRecordSet("dteFlightTime") = sourceRecordset("dteFlightTimeDefault")
> > targetRecordSet("txtCity") = sourceRecordset("txtCityDefault")
> > targetRecordSet("lngClientId") = sourceRecordset("lngClientId")
> > targetRecordSet.Update
> > sourceRecordset.MoveNext
> > Wend
> > Set targetRecordSet = Nothing
> > Set sourceRecordset = Nothing
> > Me.Requery
> > End Sub
> >
> > Can anyone explain to me which one is the variable (text box) and where to
> > put these code and do i need any module added before it?
> >
> > For further information please look at my last post on "Transportation For
> > Data !!"
> >
> > Thanks in advance.
> >
> > Kennykee (newbie in VBA)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I differentiate between duplicate ranks? =?Utf-8?B?UGV6?= Microsoft Excel Worksheet Functions 1 27th Mar 2006 12:12 AM
differentiate empty and zero RB Smissaert Microsoft Excel Programming 2 14th Sep 2004 01:07 PM
Differentiate VPN from PPP. Abhay Misra Microsoft Windows 2000 Networking 1 20th Jul 2004 11:47 AM
differentiate between modes lynn atkinson Microsoft Access Forms 2 17th Mar 2004 10:32 AM
How do I differentiate ATA 100/133 cables? Moonlit DIY PC 4 25th Sep 2003 07:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:08 PM.