Neuigkeiten:

Wenn ihr euch für eine gute Antwort bedanken möchtet, im entsprechenden Posting einfach den Knopf "sag Danke" drücken!

Mobiles Hauptmenü

Durch API verstecktes Fenster: Formulare einblenden/anzeigen lassen

Begonnen von Kladdi, Februar 20, 2013, 14:48:32

⏪ vorheriges - nächstes ⏩

Kladdi

Hallo zusammen,

nachdem meine letzte Frage schon so schön schnell beantwortet worden ist, kommt hier direkt die nächste:

Wie schaffe ich es, wenn ich durch unten stehenden Code mein Hauptfenster ausgeblendet habe, über das jetzt noch sichtbare Formular zu einem anderen zu navigieren, es zu öffnen und vor allem ANZEIGEN zu lassen?

Ich habe für alle Formulare die ich versucht habe zu öffnen, die Option "Pop Up" auf "Ja" gestellt, wie es in folgendem Link beschrieben wurde.

http://support.microsoft.com/kb/510049/de


Option Compare Database
Option Explicit

'Needed to hide the normal Access window
[color=red]Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Declare Function ShowWindow Lib "user32" _
   (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long[/color]


Private Sub Execute_Click() 'Mainpage the Execute-Button, if its one click this code is executed
   'Variables
   Dim strStatusCombo As String
   
   'The status of the Combobox (returns a string)
   strStatusCombo = Me.MainPageCombobox.Value
   
   'Query: Status of the Combobox
   Select Case strStatusCombo
   
   Case Is = "Please choose an option!"
       'If nothing had been chosen the user gets a warning
       MsgBox "You haven't chosen an option!", vbCritical, "Failure"
       
   Case Is = "Upload: New COMPASS-Data"
       'Execute the subroutine which uploads the new data from COMPASS
       modImportCOMPASSData.EnterCOMPASSData
   
   Case Is = "Upload: New Forecast-Data"
       MsgBox "Upload!"
       
   Case Is = "Creat:  New Excelsheet for the Towerleads"
       MsgBox "Creat Excel for Towerlead (all?/single?)"
       
   Case Is = "Creat:  New Forecastreport"
       MsgBox "Creat Excel-Report"
       
   Case Is = "Change: WBS-Structure"
       MsgBox "Change WBS"
       
   Case Is = "Maintenance Area"
       [color=red]DoCmd.OpenForm "MaintenanceAreaLogin", acNormal, , , , acWindowNormal
       DoCmd.SelectObject acForm, "MainPage"
       DoCmd.Close
       [/color]
       
   Case Else
       MsgBox "Shouldn't be possible!"
   End Select
   
   
End Sub


Private Sub Exit_Click()
   DoCmd.Quit
End Sub

Private Sub Form_Load()

'Versteckt das normale Accessfenster
[color=red]   Dim hWindow As Long
  Dim nResult As Long
  Dim nCmdShow As Long
 
  hWindow = Application.hWndAccessApp
  nCmdShow = SW_HIDE
  nResult = ShowWindow(ByVal hWindow, ByVal nCmdShow)
  Call ShowWindow(Me.hwnd, SW_NORMAL)[/color]
'---------------------------------------------------------------------------------
'Initiiert die Combobox
With Me.MainPageCombobox
   'Add the options which the user can select
   .AddItem "Please choose an option!"
   .AddItem "Upload: New COMPASS-Data"
   .AddItem "Upload: New Forecast-Data"
   .AddItem "Create:  New Excelsheet"
   .AddItem "Create:  New Forecastreport"
   .AddItem "Change: WBS-Structure"
   .AddItem "Maintenance Area"
   
   
   .RowSourceType = "Value List"       'The option Value List is chosen to work with an integer ListIndex
   .SetFocus                           'The focus has to been set to chose the ListIndex
   .ListRows = 7                       'The Number of rows shown in the box !!!If options are added or deleted, you've to change the number!!!
   .ListIndex = 0                      'The position of the Item which is shown at the start
End With
End Sub



Dies hier ist der komplette Code für mein Hauptformular, ich habe die Teile die diese Frage betreffen (hoffentlich) alle rot gekennzeichnet, falls euch ansonsten noch Verbesserungsvorschläge einfallen wäre ich auch für diese dankbar.

Ok, grade kam die Erkenntnis, das das mit dem rot färben in der Codebox leider nicht geht, ihr erkennt den Code daran dass er in dem Befehl eingeschlossen ist.

MfG

Kladdi

database

Hallo,

setze auf dein Formular einen Button und trage ins Klick-Ereignis folgenden Code ein.


Private Sub DeinButton_Click()

Dim xyz
xyz = ShowWindow(Application.hWndAccessApp, 2)

DoCmd.OpenForm "DeinGewünschtesFormular"
DoCmd.Close acForm, "DasAktuelleFormular"

End Sub


Die zu öffnenden Formulare stellst du folgendermaßen ein:

PopUp - ja
Größe anpassen - ja
Zentrieren - ja
Gebunden - ja
Rahmenart - dünn

Und nicht vergessen - du benötigst einen Button um Access sauber zu beenden!

DoCmd.Quit

Sonst kannst du Access nur noch über den Taskmanager 'abschießen'

HTH

Kladdi

Vielen Dank,

läuft genau wie gewollt, die Knöpfe waren mitsamt ihrer Events schon implementiert.
Und auch die (Formular-) Fenster hatte ich schon fertig eingestellt.

Da hatte ich ein ziemliches Brett vor dem Kopf wenn man den Funktionsnamen bedenkt. -.-