Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Excel & MS Query caused compile errors

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel & MS Query caused compile errors

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Excel & MS Query caused compile errors

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
.... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel & MS Query caused compile errors

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Excel & MS Query caused compile errors

Hi Joel,

Im sorry for the confusion I caused. My data is in an Excel file called
Excelhanding.xls. The format of it were distorted after copying and pasting.
It should be:
Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 30/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 Mar 88 4.5711 A0004 30/09/2003 1990
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A0005 31/12/1989 €¦
31 Dec 89 3.0482 A0005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦
... €¦ €¦ 2005
€¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦
A0005 31/12/2005 2001 €¦ 2005
€¦
Youre absolutely right.! For Column A, I only have monthly data from Jan
31, 1988 to Dec 31, 2005. It is feasible to €œopen the database and retrieve
the data one row at a time€. I just think it will be a good exercise to learn
SQL. After all, I always in a situation where I need to change Jan 31 88 to
31/12/1988 and to compare two columns.

1) Id like to €œformat the data which already exists in the Excel
worksheet€. That said, I need to fill the Column F with the content of Column
B within this Excelhandling.xls. Im reading two books on SQL Server 2005
Programming, a book on Excel and a book called €œIntegrating Excel and
Access€, which also talked some basic Microsoft Visual Basic (VBA). However,
after all this reading, Im still confused about whether I should use
Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query
(to write a program using the SQL window). I dont think I can use Macros
though.

2) The purpose of changing the format of Column A, is to be able to compare
with Column D. Since, for example, Column A is 31 Dec 2001, I guess I have to
change it to 31/12/2001 to be recognized. This 31/12/2001 stands for the
period of 01/12/2001 to 31/12/2001. 30/12/2001 in Column D falls into this
period. Therefore 3.1124 in Column B is put the place in Column F. That is
also the reason the date does not matter. As long as Dec 01 in Column A is
correspond to 12/2001 in Column D, we can put this 3.1124 to the right place
in Column F. I realize that I can do it manually but I think it will be a
good exercise to learn SQL. After all, I always in a situation where I need
to change Jan 31 88 to 31/12/1988 and to compare two columns.

3) As for the content of Column A to D, it has already been filled with
data. Im aware that it perhaps is too much to ask to let you write the
whole program (to fill Column F) for me, but Im really stuck here. May I
write some codes to let you see what problem do I have from time to time,
please?

Thank you so much for your time and input!

--
Tatiana


"Joel" wrote:

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel & MS Query caused compile errors

See below

"Greenwind" wrote:

Hi Joel,

Im sorry for the confusion I caused. My data is in an Excel file called
Excelhanding.xls. The format of it were distorted after copying and pasting.
It should be:
Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 30/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 Mar 88 4.5711 A0004 30/09/2003 1990
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A0005 31/12/1989 €¦
31 Dec 89 3.0482 A0005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦
... €¦ €¦ 2005
€¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦
A0005 31/12/2005 2001 €¦ 2005
€¦
Youre absolutely right.! For Column A, I only have monthly data from Jan
31, 1988 to Dec 31, 2005. It is feasible to €œopen the database and retrieve
the data one row at a time€. I just think it will be a good exercise to learn
SQL. After all, I always in a situation where I need to change Jan 31 88 to
31/12/1988 and to compare two columns.

1) Id like to €œformat the data which already exists in the Excel
worksheet€. That said, I need to fill the Column F with the content of Column
B within this Excelhandling.xls. Im reading two books on SQL Server 2005
Programming, a book on Excel and a book called €œIntegrating Excel and
Access€, which also talked some basic Microsoft Visual Basic (VBA). However,
after all this reading, Im still confused about whether I should use
Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query
(to write a program using the SQL window). I dont think I can use Macros
though.

-------------------------------------------------------------------------------------------
You don't need a server for SQL. the SQL is really the CommandText portion
of the query. Dont learn SQL let Excel generate it for you. Start recording
a macro from the worksheet menu - tools - Macro _record New Macro. Then
perform a query by going to worksheet menu Data - Import External Data.
Choose any of the query methods.


-------------------------------------------------------------------------------------------

2) The purpose of changing the format of Column A, is to be able to compare
with Column D. Since, for example, Column A is 31 Dec 2001, I guess I have to
change it to 31/12/2001 to be recognized. This 31/12/2001 stands for the
period of 01/12/2001 to 31/12/2001. 30/12/2001 in Column D falls into this
period. Therefore 3.1124 in Column B is put the place in Column F. That is
also the reason the date does not matter. As long as Dec 01 in Column A is
correspond to 12/2001 in Column D, we can put this 3.1124 to the right place
in Column F. I realize that I can do it manually but I think it will be a
good exercise to learn SQL. After all, I always in a situation where I need
to change Jan 31 88 to 31/12/1988 and to compare two columns.


You can compare just the month and year

ColA_Date = Range("A2")
ColD_Date = Range("D2")

if month(ColA_Date) = month(ColD_Date) and _
year(ColA_Date) = year(ColD_Date) then

You can also force the date to the 1st of the month

ColA_Date = Range("A2")
FirstDay = DateSerial(year(ColA_Date), month(ColA_Date), 1)

You can also force the date to the last day of the month by going to 1st of
next month and subtracting 1 and it even works if the date is in December.
VBA thinks there are 13 months

MyDate = "12/13/09"
LastDate = DateSerial(Year(MyDate), Month(MyDate) + 1, 1) - 1






3) As for the content of Column A to D, it has already been filled with
data. Im aware that it perhaps is too much to ask to let you write the
whole program (to fill Column F) for me, but Im really stuck here. May I
write some codes to let you see what problem do I have from time to time,
please?


I would write the entire code for you but your wouldn't learn as much as
doing it yourself. I will help.

Thank you so much for your time and input!

--
Tatiana


"Joel" wrote:

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel & MS Query caused compile errors

See below

"Greenwind" wrote:

Hi Joel,

Im sorry for the confusion I caused. My data is in an Excel file called
Excelhanding.xls. The format of it were distorted after copying and pasting.
It should be:
Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 30/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 Mar 88 4.5711 A0004 30/09/2003 1990
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A0005 31/12/1989 €¦
31 Dec 89 3.0482 A0005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦
... €¦ €¦ 2005
€¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦
A0005 31/12/2005 2001 €¦ 2005
€¦
Youre absolutely right.! For Column A, I only have monthly data from Jan
31, 1988 to Dec 31, 2005. It is feasible to €œopen the database and retrieve
the data one row at a time€. I just think it will be a good exercise to learn
SQL. After all, I always in a situation where I need to change Jan 31 88 to
31/12/1988 and to compare two columns.

1) Id like to €œformat the data which already exists in the Excel
worksheet€. That said, I need to fill the Column F with the content of Column
B within this Excelhandling.xls. Im reading two books on SQL Server 2005
Programming, a book on Excel and a book called €œIntegrating Excel and
Access€, which also talked some basic Microsoft Visual Basic (VBA). However,
after all this reading, Im still confused about whether I should use
Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query
(to write a program using the SQL window). I dont think I can use Macros
though.

-------------------------------------------------------------------------------------------
You don't need a server for SQL. the SQL is really the CommandText portion
of the query. Dont learn SQL let Excel generate it for you. Start recording
a macro from the worksheet menu - tools - Macro _record New Macro. Then
perform a query by going to worksheet menu Data - Import External Data.
Choose any of the query methods.


-------------------------------------------------------------------------------------------

2) The purpose of changing the format of Column A, is to be able to compare
with Column D. Since, for example, Column A is 31 Dec 2001, I guess I have to
change it to 31/12/2001 to be recognized. This 31/12/2001 stands for the
period of 01/12/2001 to 31/12/2001. 30/12/2001 in Column D falls into this
period. Therefore 3.1124 in Column B is put the place in Column F. That is
also the reason the date does not matter. As long as Dec 01 in Column A is
correspond to 12/2001 in Column D, we can put this 3.1124 to the right place
in Column F. I realize that I can do it manually but I think it will be a
good exercise to learn SQL. After all, I always in a situation where I need
to change Jan 31 88 to 31/12/1988 and to compare two columns.


You can compare just the month and year

ColA_Date = Range("A2")
ColD_Date = Range("D2")

if month(ColA_Date) = month(ColD_Date) and _
year(ColA_Date) = year(ColD_Date) then

You can also force the date to the 1st of the month

ColA_Date = Range("A2")
FirstDay = DateSerial(year(ColA_Date), month(ColA_Date), 1)

You can also force the date to the last day of the month by going to 1st of
next month and subtracting 1 and it even works if the date is in December.
VBA thinks there are 13 months

MyDate = "12/13/09"
LastDate = DateSerial(Year(MyDate), Month(MyDate) + 1, 1) - 1






3) As for the content of Column A to D, it has already been filled with
data. Im aware that it perhaps is too much to ask to let you write the
whole program (to fill Column F) for me, but Im really stuck here. May I
write some codes to let you see what problem do I have from time to time,
please?


I would write the entire code for you but your wouldn't learn as much as
doing it yourself. I will help.

Thank you so much for your time and input!

--
Tatiana


"Joel" wrote:

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Excel & MS Query caused compile errors

Hi Joel,

Im sorry for the confusion I caused. My data is in an Excel file called
Excelhanding.xls. The format of it were distorted after copying and pasting.
It should be:
Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 30/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 Mar 88 4.5711 A0004 30/09/2003 1990
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A0005 31/12/1989 €¦
31 Dec 89 3.0482 A0005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦
... €¦ €¦ 2005
€¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦
A0005 31/12/2005 2001 €¦ 2005
€¦
Youre absolutely right.! For Column A, I only have monthly data from Jan
31, 1988 to Dec 31, 2005. It is feasible to €œopen the database and retrieve
the data one row at a time€. I just think it will be a good exercise to learn
SQL. After all, I always in a situation where I need to change Jan 31 88 to
31/12/1988 and to compare two columns.

1) Id like to €œformat the data which already exists in the Excel
worksheet€. That said, I need to fill the Column F with the content of Column
B within this Excelhandling.xls. Im reading two books on SQL Server 2005
Programming, a book on Excel and a book called €œIntegrating Excel and
Access€, which also talked some basic Microsoft Visual Basic (VBA). However,
after all this reading, Im still confused about whether I should use
Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query
(to write a program using the SQL window). I dont think I can use Macros
though.

2) The purpose of changing the format of Column A, is to be able to compare
with Column D. Since, for example, Column A is 31 Dec 2001, I guess I have to
change it to 31/12/2001 to be recognized. This 31/12/2001 stands for the
period of 01/12/2001 to 31/12/2001. 30/12/2001 in Column D falls into this
period. Therefore 3.1124 in Column B is put the place in Column F. That is
also the reason the date does not matter. As long as Dec 01 in Column A is
correspond to 12/2001 in Column D, we can put this 3.1124 to the right place
in Column F. I realize that I can do it manually but I think it will be a
good exercise to learn SQL. After all, I always in a situation where I need
to change Jan 31 88 to 31/12/1988 and to compare two columns.

3) As for the content of Column A to D, it has already been filled with
data. Im aware that it perhaps is too much to ask to let you write the
whole program (to fill Column F) for me, but Im really stuck here. May I
write some codes to let you see what problem do I have from time to time,
please?

Thank you so much for your time and input!

--
Tatiana


"Joel" wrote:

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel & MS Query caused compile errors

I have lots of quetions but lets take it slow at first.

Your error message is being cause because you are trying to modify a
worksheet that is linked by a query to a database. You need to copy the data
to a new sheet to be able to modify the data. The code below will
automaticaly copy the data to an existing worksheet

Sub CopySheet()

Set Sourcesht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Sourcesht.Cells.Copy Destination:=DestSht.Cells

End Sub


1) My problem with your posting is I'm not sure is you need to query the
database to get additional data or you are just formating the data that
already exists on the worksheet. Instead of qerying the database you can
actually open the database and retrieve the data one row at a time.

2) I also need futher explaination with your statment of dates "I have to
change them to the same format". You don't mean formating the cells on the
worksheet but make the dates the same time reference that same such as the
last date of the month.

3) I think you should start by filling in the missing dates in columns A - D
to make it easier to perform lookups. You can do this automatically with
code.

I think you want to attempt to do most of the work yourself with me advising?


"Greenwind" wrote:

I'm sorry for hijacking this question but somehow I just cannot post any new
question here.

My data is in an Excel file and I'd like to fill a column within this file.
After connecting this file to MS Query, Id like to compare Column A and D
then use the content of Cloumn B to fill column F.

There are 3 groups in my data. Group 1: Column A & Column B.
Group 2: Column C & D. Group 3: Column E and F. Column A has monthly data
from Jan 1988 to Jan 2006. Notice although 31 Jan 88 is a date, it means a
period from Jan 01, 1988 to Jan 31, 1988. Both dates, Jan 01, 1988 and Jan
31, 1988 are included. Column B is the debt of the corresponding month. e.g.
From Jan 01, 1988 to Jan 31, 1988, the debt is 2.3343. Column C and D are the
companies names and debt issuing dates respectively. In column C, there are
848 different firms. However, the starting and end dates are different in
these two columns. That is, according to column D, company A0004 does not
have any issuing dates during 1988-2000. The issuing dates for A0004 only
exist
during 2001 and 2005. There is another example: A0005s issuing dates are
from 1989 to 2005. Column E has 848 firms although firms names are not
listed in column E. Each firm has a fixed format which starts with 1988 and
finishes with 2005 in column E.

Column A Column B Column C Column D Column E Column F
Time Debt Company Issuing date Year Arranged Debt
31 Jan 88 2.3343 A0004 31/12/2001 1988 3.0045
28 Feb 88 3.5674 A0004 30/04/2002 1989 3.0482
31 March 4.5711 A0004 30/09/2003 €¦
€¦ €¦ A0004 01/04/2004 €¦
31 Dec 88 3.0045 A0004 30/09/2005 €¦
€¦ €¦ A005 31/12/1989 €¦
31 Dec 89 3.0482 A005 31/12/1990 €¦
31 Dec 01 3.1124 €¦ €¦ €¦
€¦ €¦ €¦ €¦ €¦
31 Dec 05 4.5711 €¦ €¦ 2001 3.1124
€¦ €¦ €¦ €¦ €¦
€¦ €¦ €¦ €¦ 2005
€¦ €¦ €¦ €¦ 1988
€¦ €¦ €¦ €¦ €¦
... ... A005 31/12/2005 2001
€¦ €¦ €¦

€¦ €¦ 2005
€¦ €¦ €¦
In order to compare Column A and D, I have to change them to the same
format. Effectively if the the month in Column A and D are the same, I can
put the content of Column B into Column F. For instance, because 31/12/2001
corresponds to 31 Dec 01 in Column A, 3.1124 should be placed after the 2001
in column E for firm A0004.

As for the 1st and the 2nd cell in column F, the year-end-values in column B
are used. Based on column D, there is no issuing date for A0004 during
1988-2000. Therefore, we assume the issuing date for A0004 in 1998 is the
last date of 1988, i.e. 31 Dec 88. Hence 3.0045 is put in the 1st cell in
column F. Similarly, 3.0482 is placed after 1989 in column E.

I tried the first step: SELECT Time
UPDATE Time
SET Time = 31/01/1988
WHERE Time = 31 Jan 88
The error message is: Syntax error in query expression 'Time UPDATE Time SET
Time = 31/01/1988 WHERE Time = 31 Jan 88'. Why?

Thank you so much!


--
Tatiana


"Joel" wrote:

You didn't specify what happened to cause the problem. did you perform any
updates to windows, Office, or other products that may of caused the cahnge.
Do yo uhave your window updates set in automatic update mode or did your MIS
department push some updates on your PC?

I suspect one of the DLL got updated.check the References in the VBA menu
tools - References and see if any of the select libraries got updated.

"Simon Shaw" wrote:

Hi,

After connecting to BusinessVision tables and returning data to Excel, my
VBA code in excel suddenly became un-compileable. Simple code syntax such as
declaring a variable was suddenly invalid. I would comment out the offending
lines to see what else failed, and stopped after about the 12th code failure.

The code compiles fine in numerous environments and runs in Excel 2000, 2003
& 2007 against Pervasive, MS Access, SQL Server, My SQL and Oracle databases.

The error occurs just after manually querying BusinessVision 7.3 with
Pervasive 10 database with Excel for the first time.

Fix Attempts include:
- Uninstalling/re-installing Excel
- removing and adding the System DSN files in the ODBC Drivers
- uninstalling BusinessVision and pervasive
- applying all updates to Excel, BusinessVision and the OS.
none worked

I then started with a clean windows server, installed excel, then installed
BusinessVision. the VBA code still compiled. I then added the System DSN
file. the VBA code still compiled fine. I then performed a manual database
query to retrieve data from the AR - Transaction tables, which was
successful. I then tried to compile the VBA code and it failed - miserably...
:(

thoughts?

Thank you!

--
Simon Shaw, CA | President | Kode101 Inc.
www.kode101.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent function errors caused by cutting & paste or drag & drop Learning More Each Day Excel Worksheet Functions 2 November 2nd 09 09:42 PM
FORMULA ERRORS CAUSED BY SPACEBAR Gator Girl Excel Worksheet Functions 12 January 12th 09 09:59 PM
Uninstall of mappoint has caused errors with excel ChuckW Excel Discussion (Misc queries) 1 August 23rd 05 07:05 PM
Compile Errors with Different versions of Excel PStephens Excel Discussion (Misc queries) 2 March 14th 05 04:27 PM
Excel 97 Macro Compile Errors Simon[_15_] Excel Programming 1 May 10th 04 01:37 PM


All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"