Option Compare Database
Private Sub Form_Open(Cancel As Integer)
‘ Minimize the database window and initialize the form.
‘ Move to the switchboard page that is marked as the default.
Me.Filter = «[ItemNumber] = 0 AND [Argument] = ‘По умолчанию’ «
Me.FilterOn = True
End Sub
Private Sub Form_Current()
‘ Update the caption and fill in the list of options.
Me.Caption = Nz(Me![ItemText], «»)
FillOptions
End Sub
Private Sub FillOptions()
‘ Fill in the options for this switchboard page.
‘ The number of buttons on the form.
Const conNumButtons = 8
Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer
‘ Set the focus to the first button on the form,
‘ and then hide all of the buttons on the form
‘ but the first. You can’t hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me(«Option» & intOption).Visible = False
Me(«OptionLabel» & intOption).Visible = False
Next intOption
‘ Open the table of Switchboard Items, and find
‘ the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = «SELECT * FROM [Switchboard Items]»
stSql = stSql & » WHERE [ItemNumber] > 0 AND [SwitchboardID]=» & Me![SwitchboardID]
stSql = stSql & » ORDER BY [ItemNumber];»
Set rs = CreateObject(«ADODB.Recordset»)
rs.Open stSql, con, 1 ‘ 1 = adOpenKeyset
‘ If there are no options for this Switchboard Page,
‘ display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = «На странице кнопочной формы нет элементов»
Else
While (Not (rs.EOF))
Me(«Option» & rs![ItemNumber]).Visible = True
Me(«OptionLabel» & rs![ItemNumber]).Visible = True
Me(«OptionLabel» & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If
‘ Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing
End Sub
Private Function HandleButtonClick(intBtn As Integer)
‘ This function is called when a button is clicked.
‘ intBtn indicates which button was clicked.
‘ Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9
‘ An error that is special cased.
Const conErrDoCmdCancelled = 2501
Dim con As Object
Dim rs As Object
Dim stSql As String
On Error GoTo HandleButtonClick_Err
‘ Find the item in the Switchboard Items table
‘ that corresponds to the button that was clicked.
Set con = Application.CurrentProject.Connection
Set rs = CreateObject(«ADODB.Recordset»)
stSql = «SELECT * FROM [Switchboard Items] «
stSql = stSql & «WHERE [SwitchboardID]=» & Me![SwitchboardID] & » AND [ItemNumber]=» & intBtn
rs.Open stSql, con, 1 ‘ 1 = adOpenKeyset
‘ If no item matches, report the error and exit the function.
If (rs.EOF) Then
MsgBox «Ошибка при чтении таблицы Switchboard Items.»
rs.Close
Set rs = Nothing
Set con = Nothing
Exit Function
End If
Select Case rs![Command]
‘ Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = «[ItemNumber] = 0 AND [SwitchboardID]=» & rs![Argument]
‘ Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd
‘ Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]
‘ Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview
‘ Customize the Switchboard.
Case conCmdCustomizeSwitchboard
‘ Handle the case where the Switchboard Manager
‘ is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run «ACWZMAIN.sbm_Entry»
If (Err <> 0) Then MsgBox «Команда недоступна.»
On Error GoTo 0
‘ Update the form.
Me.Filter = «[ItemNumber] = 0 AND [Argument] = ‘По умолчанию’ «
Me.Caption = Nz(Me![ItemText], «»)
FillOptions
‘ Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase
‘ Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]
‘ Run code.
Case conCmdRunCode
Application.Run rs![Argument]
‘ Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]
‘ Any other command is unrecognized.
Case Else
MsgBox «Неизвестная команда.»
End Select
‘ Close the recordset and the database.
rs.Close
HandleButtonClick_Exit:
On Error Resume Next
Set rs = Nothing
Set con = Nothing
Exit Function
HandleButtonClick_Err:
‘ If the action was cancelled by the user for
‘ some reason, don’t display an error message.
‘ Instead, resume on the next line.
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox «Ошибка при выполнении команды.», vbCritical
Resume HandleButtonClick_Exit
End If
End Function
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Contact US
Thanks. We have received your request and will respond promptly.
Log In
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips Forums!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts - Keyword Search
- One-Click Access To Your
Favorite Forums - Automated Signatures
On Your Posts - Best Of All, It’s Free!
*Tek-Tips’s functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Posting Guidelines
Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Students Click Here
«There was an error reading the Switchboard Items table»«There was an error reading the Switchboard Items table»(OP) 22 Mar 04 10:58 i have x-posted this query to the Access Tables forum since it seems to have its origins in each basically i have created a fledgling s/board using the Switchboard Manager and on attempting to use the s/b am confronted with a single button telling me there are no s/b items on this page!! clicking on the menu button results in the message in my heading. i’m inexpert enough not to know whether there is or isn’t anything fundamentally awry with the table they’re talking about. also, i am able to create new and/or modify existing s/b commands using the s/b manager even though on attempting to use the s/b i get this anomalous behavior. anyone out there have this kind of thing meet up w/ ’em? i’d sure appreciate a way out of it. “The philosophy of the school room in one generation will be the philosophy of government in the next.» — Abraham Lincoln Red Flag SubmittedThank you for helping keep Tek-Tips Forums free from inappropriate posts. |
Join Tek-Tips® Today!
Join your peers on the Internet’s largest technical computer professional community.
It’s easy to join and it’s free.
Here’s Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More…
Register now while it’s still free!
Already a member? Close this window and log in.
Join Us Close
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
‘ Minimize the database window and initialize the form.
‘ Move to the switchboard page that is marked as the default.
Me.Filter = «[ItemNumber] = 0 AND [Argument] = ‘По умолчанию’ «
Me.FilterOn = True
End Sub
Private Sub Form_Current()
‘ Update the caption and fill in the list of options.
Me.Caption = Nz(Me![ItemText], «»)
FillOptions
End Sub
Private Sub FillOptions()
‘ Fill in the options for this switchboard page.
‘ The number of buttons on the form.
Const conNumButtons = 8
Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer
‘ Set the focus to the first button on the form,
‘ and then hide all of the buttons on the form
‘ but the first. You can’t hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me(«Option» & intOption).Visible = False
Me(«OptionLabel» & intOption).Visible = False
Next intOption
‘ Open the table of Switchboard Items, and find
‘ the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = «SELECT * FROM [Switchboard Items]»
stSql = stSql & » WHERE [ItemNumber] > 0 AND [SwitchboardID]=» & Me![SwitchboardID]
stSql = stSql & » ORDER BY [ItemNumber];»
Set rs = CreateObject(«ADODB.Recordset»)
rs.Open stSql, con, 1 ‘ 1 = adOpenKeyset
‘ If there are no options for this Switchboard Page,
‘ display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = «На странице кнопочной формы нет элементов»
Else
While (Not (rs.EOF))
Me(«Option» & rs![ItemNumber]).Visible = True
Me(«OptionLabel» & rs![ItemNumber]).Visible = True
Me(«OptionLabel» & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If
‘ Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing
End Sub
Private Function HandleButtonClick(intBtn As Integer)
‘ This function is called when a button is clicked.
‘ intBtn indicates which button was clicked.
‘ Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9
‘ An error that is special cased.
Const conErrDoCmdCancelled = 2501
Dim con As Object
Dim rs As Object
Dim stSql As String
On Error GoTo HandleButtonClick_Err
‘ Find the item in the Switchboard Items table
‘ that corresponds to the button that was clicked.
Set con = Application.CurrentProject.Connection
Set rs = CreateObject(«ADODB.Recordset»)
stSql = «SELECT * FROM [Switchboard Items] «
stSql = stSql & «WHERE [SwitchboardID]=» & Me![SwitchboardID] & » AND [ItemNumber]=» & intBtn
rs.Open stSql, con, 1 ‘ 1 = adOpenKeyset
‘ If no item matches, report the error and exit the function.
If (rs.EOF) Then
MsgBox «Ошибка при чтении таблицы Switchboard Items.»
rs.Close
Set rs = Nothing
Set con = Nothing
Exit Function
End If
Select Case rs![Command]
‘ Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = «[ItemNumber] = 0 AND [SwitchboardID]=» & rs![Argument]
‘ Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd
‘ Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]
‘ Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview
‘ Customize the Switchboard.
Case conCmdCustomizeSwitchboard
‘ Handle the case where the Switchboard Manager
‘ is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run «ACWZMAIN.sbm_Entry»
If (Err <> 0) Then MsgBox «Команда недоступна.»
On Error GoTo 0
‘ Update the form.
Me.Filter = «[ItemNumber] = 0 AND [Argument] = ‘По умолчанию’ «
Me.Caption = Nz(Me![ItemText], «»)
FillOptions
‘ Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase
‘ Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]
‘ Run code.
Case conCmdRunCode
Application.Run rs![Argument]
‘ Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]
‘ Any other command is unrecognized.
Case Else
MsgBox «Неизвестная команда.»
End Select
‘ Close the recordset and the database.
rs.Close
HandleButtonClick_Exit:
On Error Resume Next
Set rs = Nothing
Set con = Nothing
Exit Function
HandleButtonClick_Err:
‘ If the action was cancelled by the user for
‘ some reason, don’t display an error message.
‘ Instead, resume on the next line.
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox «Ошибка при выполнении команды.», vbCritical
Resume HandleButtonClick_Exit
End If
End Function
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Contact US
Thanks. We have received your request and will respond promptly.
Log In
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips Forums!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts - Keyword Search
- One-Click Access To Your
Favorite Forums - Automated Signatures
On Your Posts - Best Of All, It’s Free!
*Tek-Tips’s functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Posting Guidelines
Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Students Click Here
«There was an error reading the Switchboard Items table»«There was an error reading the Switchboard Items table»(OP) 22 Mar 04 10:58 i have x-posted this query to the Access Tables forum since it seems to have its origins in each basically i have created a fledgling s/board using the Switchboard Manager and on attempting to use the s/b am confronted with a single button telling me there are no s/b items on this page!! clicking on the menu button results in the message in my heading. i’m inexpert enough not to know whether there is or isn’t anything fundamentally awry with the table they’re talking about. also, i am able to create new and/or modify existing s/b commands using the s/b manager even though on attempting to use the s/b i get this anomalous behavior. anyone out there have this kind of thing meet up w/ ’em? i’d sure appreciate a way out of it. “The philosophy of the school room in one generation will be the philosophy of government in the next.» — Abraham Lincoln Red Flag SubmittedThank you for helping keep Tek-Tips Forums free from inappropriate posts. |
Join Tek-Tips® Today!
Join your peers on the Internet’s largest technical computer professional community.
It’s easy to join and it’s free.
Here’s Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More…
Register now while it’s still free!
Already a member? Close this window and log in.
Join Us Close
0 / 0 / 0 Регистрация: 12.04.2023 Сообщений: 4 |
|
1 |
|
Как избавиться от данной ошибки?08.05.2023, 20:18. Показов 550. Ответов 19
При открытии бд выскакивает ошибка
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
08.05.2023, 20:44 |
2 |
Gogorik, не факт, что поможет. Причин может быть много Код DLookUp("SwitchboardID","[Switchboard Items]","[ItemNumber] = 0 AND [Argument] = 'По умолчанию'")
0 |
8774 / 5627 / 577 Регистрация: 27.03.2013 Сообщений: 19,072 |
|
08.05.2023, 20:49 |
3 |
…В названии есть пробел…. Название, Надпись, Подпись, на это ни как повлиять не могут.
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
08.05.2023, 21:42 |
4 |
Только — Имя имеет значение. Т.е., если я назову тебя нудным или педатнтичным — это значения иметь не будет.
0 |
8774 / 5627 / 577 Регистрация: 27.03.2013 Сообщений: 19,072 |
|
08.05.2023, 21:54 |
5 |
…Т.е., если я назову тебя нудным… Ни сколько не обидюсь, и даже сочту это за комплимент.
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
08.05.2023, 21:57 |
6 |
и даже сочту это за комплимент. ну и правильно. Ты же видел куда я эти квадратные скобки воткнул.
0 |
8774 / 5627 / 577 Регистрация: 27.03.2013 Сообщений: 19,072 |
|
08.05.2023, 22:10 |
7 |
…Ты же видел… Я то видю и могу даже интерпретировать, варьировать, а то и вааще — тестировать , а вот ТСы, не все и не всегда. Добавлено через 34 секунды
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
08.05.2023, 22:22 |
8 |
Короче ставлю тебя на Вид. Если полегчает тебе — ставь. ТСу точно по барабану от твоих «умозаключений»
0 |
8774 / 5627 / 577 Регистрация: 27.03.2013 Сообщений: 19,072 |
|
08.05.2023, 22:24 |
9 |
от твоих «умозаключений» Это не умозаключения, а принципы и закономерности.
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
08.05.2023, 23:44 |
10 |
Название, Надпись, Подпись, на это ни как повлиять не могут.
Это не умозаключения, а принципы и закономерности. Проясни где принцип, а где закономерность.
0 |
8774 / 5627 / 577 Регистрация: 27.03.2013 Сообщений: 19,072 |
|
09.05.2023, 08:16 |
11 |
…Проясни где… Ты не маленький и сам знаешь, что если стараться всё делать как это заповедовали — ОТЦЫ-РАЗРАБОТЧИКИ, то всё будет получаться легко и просто, ибо предусмотрено и есть штатные инструменты и способы.
0 |
0 / 0 / 0 Регистрация: 12.04.2023 Сообщений: 4 |
|
09.05.2023, 15:24 [ТС] |
12 |
Добавлено через 10 минут Код DLookUp("SwitchboardID","[Switchboard Items]","[ItemNumber] = 0 AND [Argument] = 'По умолчанию'") И еще могу добавить, что эта ошибка возникает при повторном открытии бд. При первом запуске бд этой ошибки нету
0 |
17246 / 7089 / 1592 Регистрация: 21.06.2012 Сообщений: 13,315 |
|
09.05.2023, 15:41 |
13 |
С кнопочной формой в последних версиях возникают проблемы. И с самой формой и с мастером кнопочных форм.
0 |
594 / 121 / 41 Регистрация: 12.04.2015 Сообщений: 491 |
|
09.05.2023, 15:56 |
14 |
Аргементы: в макрокомандах используется не запятая, а точка с запятой т.е. «;»
0 |
0 / 0 / 0 Регистрация: 12.04.2023 Сообщений: 4 |
|
09.05.2023, 18:10 [ТС] |
15 |
glsn, где искать эту макрокоманду? Этот аргумент появляется в диалоговом окне, там ничего изменить нельзя Добавлено через 3 минуты
0 |
17246 / 7089 / 1592 Регистрация: 21.06.2012 Сообщений: 13,315 |
|
09.05.2023, 18:23 |
16 |
но у меня все сделано точно также Что точно также? У меня нет никаких макросов, только VBA. Нужно импортировать в свою базу (предварительно переименовав свою Switchboard Items и удалив кнопочную) Switchboard Items и кнопочную форму. Затем ввести непосредственно в таблице Switchboard Items страницы/строки из старой
0 |
ᴁ® 3119 / 1778 / 370 Регистрация: 13.12.2016 Сообщений: 6,090 Записей в блоге: 4 |
|
09.05.2023, 20:17 |
17 |
а куда этот код вставлять? Т.е. код сам появился из неоткуда? Вы к его написанию имеете отношение?
0 |
0 / 0 / 0 Регистрация: 12.04.2023 Сообщений: 4 |
|
09.05.2023, 21:24 [ТС] |
18 |
АЕ, при открытии бд выскакивает это диалоговое окно Миниатюры
0 |
17246 / 7089 / 1592 Регистрация: 21.06.2012 Сообщений: 13,315 |
|
09.05.2023, 21:33 |
19 |
Т.е. код сам появился из неоткуда? Вы к его написанию имеете отношение? Этот код зашит в кнопочную форму. «Продвинутые» индусы так пишут. Темы три за последнее время было — то мастер страницы/строки косо создает, то просто форма не работает, … . ТС здесь не причем, вряд ли он кнопочную форму стал изменять. Другое дело — зачем тратить больше суток своего и чужого времени, а не просто выложить огрызок своей базы из Switchboard Items и Кнопочной формы.
1 |
594 / 121 / 41 Регистрация: 12.04.2015 Сообщений: 491 |
|
09.05.2023, 23:45 |
20 |
при открытии бд выскакивает это диалоговое окно в макрокоманде поправите выражение, согласно синтаксиса поставив вместо запятых — точку с запятой
0 |
- Remove From My Forums
-
Question
-
A user is getting this message (see screen image below) as soon as they attempt to open a database.
I believe this is the 64-bit version of Access opening a database created with 32-bit version of MS Access.
However, I have modified the code to be 64-bit compatible (at least as far as I am aware).
I am able to open it without any issues.
This database uses macros which I know little about.
Do you think it would help to convert the macros to VBA code?
-
Edited by
Wednesday, September 23, 2020 6:33 PM
-
Edited by