If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
Autocounter
Here's a simpler piece of code which I've tested with both On Load and
OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#22
|
|||
|
|||
Autocounter
Sorry, AM
With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#23
|
|||
|
|||
Autocounter
Have you set a reference to DAO in your code window?
Tools References Microsoft Data Access Objects 3.6 -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry, AM With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#24
|
|||
|
|||
Autocounter
Sorry may delay.
Yes, it is. In 3th position. an "Arvin Meyer [MVP]" wrote: Have you set a reference to DAO in your code window? Tools References Microsoft Data Access Objects 3.6 -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry, AM With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#25
|
|||
|
|||
Autocounter
Sorry.
4th position: Visual Basic For Applications Microsoft Access 12.0 Objecto Library OLE Automation Microsoft DAO 3.6 Object Library SO: WindowsXP Acc: 2k7 an "Arvin Meyer [MVP]" wrote: Have you set a reference to DAO in your code window? Tools References Microsoft Data Access Objects 3.6 -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry, AM With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#26
|
|||
|
|||
Autocounter
The references are in order. There should be no problems. The code runs fine
in any mdb from Access 97 through Access 2003. Although I see no problem with it running in Access 2007, I'll test it later today. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry. 4th position: Visual Basic For Applications Microsoft Access 12.0 Objecto Library OLE Automation Microsoft DAO 3.6 Object Library SO: WindowsXP Acc: 2k7 an "Arvin Meyer [MVP]" wrote: Have you set a reference to DAO in your code window? Tools References Microsoft Data Access Objects 3.6 -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry, AM With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
#27
|
|||
|
|||
Autocounter
Look at the URL in my sig. At that website is my email address. Compact and
zip your database and email it to me. I'll figure out what you are having a problem with. Before you send the database, send an email with your full name and email address and the subject: " Autocounter" I need to whitelist you or your attachment email will be automatically deleted. -- Arvin Meyer, MCP, MVP http://www.datastrat.com |
#28
|
|||
|
|||
Autocounter
Ok, AM.
Any bug, eventually. We have checked another bugs and informed the Microsoft. Ex: Me.xxx vrs Me!Xxx; One blank space after last character when import Excel spreadsheet; Etc. Thank you so much. an "Arvin Meyer [MVP]" wrote: The references are in order. There should be no problems. The code runs fine in any mdb from Access 97 through Access 2003. Although I see no problem with it running in Access 2007, I'll test it later today. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry. 4th position: Visual Basic For Applications Microsoft Access 12.0 Objecto Library OLE Automation Microsoft DAO 3.6 Object Library SO: WindowsXP Acc: 2k7 an "Arvin Meyer [MVP]" wrote: Have you set a reference to DAO in your code window? Tools References Microsoft Data Access Objects 3.6 -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Sorry, AM With this code no problem. The problem is with expression = CountOpen() When form open, return: ! Compile error: Sintax error Thanks an "Arvin Meyer [MVP]" wrote: Here's a simpler piece of code which I've tested with both On Load and OnOpen: Function CountOpen() On Error GoTo Error_Handler Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset) With rst rst.MoveFirst rst.Edit rst!CountDB = rst!CountDB + 1 rst.Update End With Exit_He On Error Resume Next rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, Problem solved with: Private Sub Form_Load() Me.CountDB = CountOpen() End Sub In OnLoad, only. In OnOpen return: Run-time error '2448' Thank you more one time. an "an" wrote: AM, thank you for reply. Exactly, in OnLoad or in OnOpen: Private Sub Form_Open(Cancel As Integer) = CountOpen() End Sub Return too: Compile Error: Sintax Error an "Arvin Meyer [MVP]" wrote: = CountOpen() goes directly in the property sheet in the On Open or On Load event, not in a code window. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, thank you for help. When run code, return message: Compile error: Syntax error on line = CountOpen() an "Arvin Meyer [MVP]" wrote: That example was drawn from working code that's been running for years, so I'd need to see your exact implementation to debug the error. Try setting a breakpoint at the Set db line and stepping through the code to find the line producing the error. If Crystal's code is working for you, I'd just use that to avoid wasting any time. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... AM, sorry for my delay. Now, after write =CountOpen() in Open event, return: Compile error: Expected: line nunber or label or statement or end of statment. an "Arvin Meyer [MVP]" wrote: In the form's Open event property sheet, you can simply put: =CountOpen() -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Thank you for replay. One difficult: After insert your the function code in form, how call it from's open or load event, please? an "Arvin Meyer [MVP]" wrote: Understand that each user must have their own copy of the front-end of the database. Sharing a single fron-end is a leading cause of corruption. Build a 1 record table named tblDBOpen, with a single field named CountDB. Add the following code to a standard or form module and call it from the form's open or load event: Function CountOpen() As Long On Error GoTo Error_Handler Dim rst As DAO.Recordset Dim lngMax As Long Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("Select Max(CountDB) As MaxNum FROM tblDBOpen") If IsNull(rst!MaxNum) Then 'no records yet, start with one lngMax = 1 Else lngMax = rst!MaxNum + 1 End If CountOpen = lngMax Exit_He rst.Close Set rst = Nothing Set db = Nothing Exit Function Error_Handler: MsgBox Err.Number & ": " & Err.Description Resume Exit_Here End Function -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "an" wrote in message ... Hi! I would like to insert a counter, for exemple in F_Main, to count how many times the DB was loaded. Is it possible in Acc2k7, please? Thanks in advance. an |
Thread Tools | |
Display Modes | |
|
|