473,659 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Code

Hi, I need some help form someone.

I use my database for my online shop, so once I have entered a order
onto the database I have a button that creates the Email to the
customer to let them know the order has been placed.

I use to use [ProductID] as a auto number but I have just changed it to
[ProductCode] Which is not a auto number as I type them in.

But now my VB code for the email button does not work.
Can any one help me

Old Code

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " & _
DLookup("[ProductName]", "tblProduct ", "[ProductID] =" &
CRS1.Fields("Pr oductID")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " & Chr(163) &
DLookup("[PriceIncVAT ]", "tblProduct ", "[ProductID] =" &
CRS1.Fields("Pr oductID")) & vbCrLf
The email use to look like this

Item : Test Strips
Qty : 2
Unit Price : £15
Total (Inc VAT): £30.00

I have changed ProductID to ProductCode in the VB code but it does not
work

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " & _
DLookup("[ProductName]", "tblProduct ", "[ProductCode] =" &
CRS1.Fields("Pr oductCode")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " & Chr(163) &
DLookup("[PriceIncVAT ]", "tblProduct ", "[ProductCode] =" &
CRS1.Fields("Pr oductCode")) & vbCrLf

Can any one help I am new to all this

Aug 12 '06 #1
2 1534
Simon wrote:
Hi, I need some help form someone.

I use my database for my online shop, so once I have entered a order
onto the database I have a button that creates the Email to the
customer to let them know the order has been placed.

I use to use [ProductID] as a auto number but I have just changed it to
[ProductCode] Which is not a auto number as I type them in.

But now my VB code for the email button does not work.
Can any one help me

Old Code

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " & _
DLookup("[ProductName]", "tblProduct ", "[ProductID] =" &
CRS1.Fields("Pr oductID")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " & Chr(163) &
DLookup("[PriceIncVAT ]", "tblProduct ", "[ProductID] =" &
CRS1.Fields("Pr oductID")) & vbCrLf
The email use to look like this

Item : Test Strips
Qty : 2
Unit Price : £15
Total (Inc VAT): £30.00

I have changed ProductID to ProductCode in the VB code but it does not
work

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " & _
DLookup("[ProductName]", "tblProduct ", "[ProductCode] =" &
CRS1.Fields("Pr oductCode")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " & Chr(163) &
DLookup("[PriceIncVAT ]", "tblProduct ", "[ProductCode] =" &
CRS1.Fields("Pr oductCode")) & vbCrLf

Can any one help I am new to all this
Go to Queries/New/Design. Add tables tblOrderProduct and tblProduct.
Link ProductCode between the two tables. Drag ProductDesc to a column
too. Then run the query. Do you get any results?

Personally, I'd save the query when you get the query correct, click
View/SQL, copy the SQL, and make strSQL that string. You'll need to
modify the SQL string with quotes as needed to separate the variable
OrderNumber like you have above but that way you don't need the Dlookup.
Aug 12 '06 #2
"Simon" <S.*******@shos .co.ukwrote in
news:11******** **************@ b28g2000cwb.goo glegroups.com:
Hi, I need some help form someone.

I use my database for my online shop, so once I have entered a
order onto the database I have a button that creates the Email
to the customer to let them know the order has been placed.

I use to use [ProductID] as a auto number but I have just
changed it to [ProductCode] Which is not a auto number as I
type them in.

But now my VB code for the email button does not work.
Can any one help me

Old Code

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " &
_
DLookup("[ProductName]", "tblProduct ", "[ProductID] ="
&
CRS1.Fields("Pr oductID")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " &
Chr(163) & DLookup("[PriceIncVAT ]", "tblProduct ",
"[ProductID] =" & CRS1.Fields("Pr oductID")) & vbCrLf
The email use to look like this

Item : Test Strips
Qty : 2
Unit Price : £15
Total (Inc VAT): £30.00

I have changed ProductID to ProductCode in the VB code but it
does not work

strSql = "SELECT * FROM tblOrderProduct WHERE OrderNumber =" &
Me.OrderNumber
CRS1.Open strSql, CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
While Not CRS1.EOF
strItemsOrdered = strItemsOrdered & "Item : " &
_
DLookup("[ProductName]", "tblProduct ", "[ProductCode]
=" &
CRS1.Fields("Pr oductCode")) & vbCrLf & "Qty : " &
CRS1.Fields("Qu antity") & vbCrLf

strItemsOrdered = strItemsOrdered & "Unit Price : " &
Chr(163) & DLookup("[PriceIncVAT ]", "tblProduct ",
"[ProductCode] =" & CRS1.Fields("Pr oductCode")) & vbCrLf

Can any one help I am new to all this
Is productID stored in a text field?

If you have changed the type from (auto) number to text, you will
have to add some delimiters (quotes) to the Dlookup code

To add delimiters inside a string that's already in a string, you
have to double thenm up.

The existing.
DLookup("[ProductName]", "tblProduct ", "[ProductID] =" &
CRS1.Fields("Pr oductID"))

needs to be
DLookup("[ProductName]", "tblProduct ", "[ProductID] =""" &
CRS1.Fields("Pr oductID") & """")

Make the same change in the other dlookup.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2747
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like storing products in
6
3006
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect an html authoring tool to help you accomplish? 2. What do you expect from online help for a html authoring tool? 3. What audience do you think a freeware html authoring tool is directed towards?
6
391
by: Mark Reed | last post by:
Hi all, I am trying to learn a little about programming (I know next to nothing so far) and have found some code which hides the toolbars. However, this bit of code is a little too effective and hides all of them including hiding the database window, disabling menu changes. What I am after is the same effect as disabling all the check boxes in startup which still leaves 'File', 'Edit', 'Insert','Records','Window' &'Help'. I want to do this...
4
2619
by: dixie | last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I have just installed HTML Help in an application. I told it in the Project Properties the path to the help file. I then type in a command line that runs the help in the correct Context from a button on each form. It all worked fine - HERE. The problem is that when I sent it out to a site, the help file was not able to be accessed because it was my path in the...
7
3301
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,
23
3260
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
16
2004
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just learning and really need some help bad. Public Shared Function GetAll() As ArrayList Dim dsCustomer As New DataSet() Dim sqlQuery As String = "SELECT Name, Address, PhoneNo " & _ "FROM CustomerTable" Try
3
3731
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a lot different from what the pros around here use. I really need help with debugging some program errors more than anything, even though my coding style might not be perfect. Anyway here is my code. About the only things that work right are...
1
2284
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre button the list is populated with a list of that genre. I have got the interface done to satisfaction, my problem is that when i press the change genre button nothing happens and when i select a track to play from the list which is setvisible and...
10
3351
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8339
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8535
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.