0
votes

First, I apologize for my english. Its not my first language.

Second, I am trying call to sub (ConfiguracionFormulario) from Form_load using like parameter input ME or Forms![REGIMEN], the name of form is REGIMEN.

I tried use "Forms![REGIMEN]" with docmd and the code run fine, but if I use variables like "Forms![FormInput.Name]" then it dont run.

I though use string parameter on ConfiguracioFormulario instead of form, and too Form_REGIMEN.

I'm sure that I have any problem of conceptually, but I'm noob on vba.

Private Sub Form_Load()
    ConfiguracionFormulario Me
End Sub

Private Sub ConfiguracionFormulario(ByRef FormInput As Form)

    Dim strFormInput As String

    strFormInput = FormInput.Name

    If FormInput.AutoCenter = False Then
    'Cerramos el formulario en vista normal, y lo abrimos en modo diseño
    DoCmd.Close acForm, strFormInput, acSaveYes
    DoCmd.OpenForm strFormInput, acDesign, , , , acHidden

    'Ajustamos las propiedades que solo pueden ser ajustadas en modo diseño
    FormatInput.AutoCenter = True

    'Cerramos el formulario en vista diseño, y lo abrimos en modo normal. Guardo configuración para no entrar en bucle
    DoCmd.Close acForm, strFormInput, acSaveYes
    DoCmd.OpenForm strFormInput, acNormal

    End If
End sub

Someone could say why this launch error message? Thanks in advance.

1

1 Answers

0
votes

Your question have many problems (and haven't solution the main question), i try to explain everyone:
1.- The code have a little bug:FormatInput.AutoCenter = True You must correct FORMATINPUT to FORMINPUT
2.- You can't use a Sub or Procedure into a Form that you use in Design Mode.
Copy always functions to any module and reuse it.
3.- You can't close your own form to try to open then... in acDesign, save, close again and reopen.
You must do this from another Form that always was open and running
4.- Why to do this is simply adding me.AutoCenter=True solve all that you need?
5.- Why not do any function that check all forms and modify properties before execute the main application? Have same result.
6.- If you want to center, why not use the form property and save during programming? It's more easy that all before.

Check your idea to the final app and it uses, could be better study what you need instead what user can be "play".