PC Review


Reply
Thread Tools Rate Thread

query values and destination fields error

 
 
Bob Vance
Guest
Posts: n/a
 
      5th Dec 2009
I am trying to get this code to add HorseID to tblDailyCharge.HorseID when I
update this form, but I am getting the error:
Number of query values and destination fields are not the same!

Private Sub subSetInvoiceDetailsValues()

CurrentProject.Connection.Execute "INSERT INTO
tblAdditionCharge(InvoiceID,ChargeID,HorseID,DayNo,ChargeNumber,AdditionCharge,
" _
& " AdditionChargeAmount)SELECT " & lngInvoiceID & "," & "ChargeID"
_
& "," & cbHorseName.value & ",DayNo,ChargeNumber,AdditionCharge, " _
& " AdditionChargeAmount FROM tmpAdditionCharge"

If IsNull(tbTotalDays1.value) = True Or tbTotalDays1.value = "" Then
Exit Sub
ElseIf IsNull(cbDailyCharge1.value) = True Or cbDailyCharge1.value = ""
Then
Exit Sub

'***TRY TO ADD HorseID HERE***
Else
CurrentProject.Connection.Execute "INSERT INTO
tblDailyCharge(InvoiceID,HorseID,StartDate,EndDate,TotalDays,DailyCharge, "
_
& " DailyChargeRate,DailyChargeAmount)Values(" & lngInvoiceID & ",'"
& Format(tbStartDate1.value, "dd/mm/yyyy") _
& "','" & Format(tbEndDate1.value, "dd/mm/yyyy") & "'," &
tbTotalDays1.value & ",'" & cbDailyCharge1.value _
& "'," & tbDailyChargeRate1.value & "," & tbDailyChargeAmount1.value
& ")"
End If
--
Thanks in advance for any help with this......Bob
MS Access 2007 accdb
Windows XP Home Edition Ver 5.1 Service Pack 3


 
Reply With Quote
 
 
 
 
Bob Vance
Guest
Posts: n/a
 
      5th Dec 2009

"Bob Vance" <(E-Mail Removed)> wrote in message
news:OrN%(E-Mail Removed)...
>I am trying to get this code to add HorseID to tblDailyCharge.HorseID when
>I update this form, but I am getting the error:
> Number of query values and destination fields are not the same!
>
> Private Sub subSetInvoiceDetailsValues()
>
> CurrentProject.Connection.Execute "INSERT INTO
> tblAdditionCharge(InvoiceID,ChargeID,HorseID,DayNo,ChargeNumber,AdditionCharge,
> " _
> & " AdditionChargeAmount)SELECT " & lngInvoiceID & "," & "ChargeID"
> _
> & "," & cbHorseName.value & ",DayNo,ChargeNumber,AdditionCharge, "
> _
> & " AdditionChargeAmount FROM tmpAdditionCharge"
>
> If IsNull(tbTotalDays1.value) = True Or tbTotalDays1.value = "" Then
> Exit Sub
> ElseIf IsNull(cbDailyCharge1.value) = True Or cbDailyCharge1.value = ""
> Then
> Exit Sub
>
> '***TRY TO ADD HorseID HERE***
> Else
> CurrentProject.Connection.Execute "INSERT INTO
> tblDailyCharge(InvoiceID,HorseID,StartDate,EndDate,TotalDays,DailyCharge,
> " _
> & " DailyChargeRate,DailyChargeAmount)Values(" & lngInvoiceID &
> ",'" & Format(tbStartDate1.value, "dd/mm/yyyy") _
> & "','" & Format(tbEndDate1.value, "dd/mm/yyyy") & "'," &
> tbTotalDays1.value & ",'" & cbDailyCharge1.value _
> & "'," & tbDailyChargeRate1.value & "," &
> tbDailyChargeAmount1.value & ")"
> End If
> --
> Thanks in advance for any help with this......Bob
> MS Access 2007 accdb
> Windows XP Home Edition Ver 5.1 Service Pack 3
>
>

OOPS HorseId is first column of cbHorseName
.Fields("HorseID") = cbHorseName.value


 
Reply With Quote
 
 
 
 
Bob Vance
Guest
Posts: n/a
 
      6th Dec 2009
THANKS,DONE IT

Private Sub subSetInvoiceDetailsValues()

CurrentProject.Connection.Execute "INSERT INTO
tblAdditionCharge(InvoiceID,ChargeID,HorseID,DayNo,ChargeNumber,AdditionCharge,
" _
& " AdditionChargeAmount)SELECT " & lngInvoiceID & "," & "ChargeID"
_
& "," & cbHorseName.value & ",DayNo,ChargeNumber,AdditionCharge, " _
& " AdditionChargeAmount FROM tmpAdditionCharge"

If IsNull(tbTotalDays1.value) = True Or tbTotalDays1.value = "" Then
Exit Sub
ElseIf IsNull(cbDailyCharge1.value) = True Or cbDailyCharge1.value = ""
Then
Exit Sub
Else
CurrentProject.Connection.Execute "INSERT INTO
tblDailyCharge(InvoiceID,StartDate,EndDate,TotalDays,DailyCharge, " _
& " DailyChargeRate,DailyChargeAmount, HorseID)Values(" &
lngInvoiceID & ",'" & Format(tbStartDate1.value, "dd/mm/yyyy") _
& "','" & Format(tbEndDate1.value, "dd/mm/yyyy") & "'," &
tbTotalDays1.value & ",'" & cbDailyCharge1.value _
& "'," & tbDailyChargeRate1.value & "," & tbDailyChargeAmount1.value
& "," & cbHorseName.value & ")"
End If


"Bob Vance" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Bob Vance" <(E-Mail Removed)> wrote in message
> news:OrN%(E-Mail Removed)...
>>I am trying to get this code to add HorseID to tblDailyCharge.HorseID when
>>I update this form, but I am getting the error:
>> Number of query values and destination fields are not the same!
>>
>> Private Sub subSetInvoiceDetailsValues()
>>
>> CurrentProject.Connection.Execute "INSERT INTO
>> tblAdditionCharge(InvoiceID,ChargeID,HorseID,DayNo,ChargeNumber,AdditionCharge,
>> " _
>> & " AdditionChargeAmount)SELECT " & lngInvoiceID & "," &
>> "ChargeID" _
>> & "," & cbHorseName.value & ",DayNo,ChargeNumber,AdditionCharge, "
>> _
>> & " AdditionChargeAmount FROM tmpAdditionCharge"
>>
>> If IsNull(tbTotalDays1.value) = True Or tbTotalDays1.value = "" Then
>> Exit Sub
>> ElseIf IsNull(cbDailyCharge1.value) = True Or cbDailyCharge1.value =
>> "" Then
>> Exit Sub
>>
>> '***TRY TO ADD HorseID HERE***
>> Else
>> CurrentProject.Connection.Execute "INSERT INTO
>> tblDailyCharge(InvoiceID,HorseID,StartDate,EndDate,TotalDays,DailyCharge,
>> " _
>> & " DailyChargeRate,DailyChargeAmount)Values(" & lngInvoiceID &
>> ",'" & Format(tbStartDate1.value, "dd/mm/yyyy") _
>> & "','" & Format(tbEndDate1.value, "dd/mm/yyyy") & "'," &
>> tbTotalDays1.value & ",'" & cbDailyCharge1.value _
>> & "'," & tbDailyChargeRate1.value & "," &
>> tbDailyChargeAmount1.value & ")"
>> End If
>> --
>> Thanks in advance for any help with this......Bob
>> MS Access 2007 accdb
>> Windows XP Home Edition Ver 5.1 Service Pack 3
>>
>>

> OOPS HorseId is first column of cbHorseName
> .Fields("HorseID") = cbHorseName.value
>



 
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
Number of query values and destination fields are not the same. thej Microsoft Access 2 13th Mar 2010 06:50 PM
Destination fields disappear from query used in subform. OldGuy Microsoft Access Form Coding 1 11th Feb 2010 05:53 PM
Error: Number of query values and destination fields are not the s =?Utf-8?B?U2VjcmV0IFNxdWlycmVs?= Microsoft Excel Worksheet Functions 0 3rd Dec 2005 03:26 AM
'Number of query values and destination fields are not same' error ralamo Microsoft Access 1 17th Mar 2005 09:53 AM
Help with query values and destination fields TC Microsoft Access Database Table Design 5 5th Sep 2003 06:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:45 AM.