open Form from form

Smrle

New member
Local time
Today, 05:03
Joined
May 31, 2019
Messages
5
Hello everyone.

I have a small problem. Lack of creativity.
I have a small (personal) database.
In the development of user forms I have imagined that the "LOCATION" form of the "ADD_" button opens the auxiliary form "SAMPLE".
In this auxiliary form is a field "CBox_ID_LOCATION" (drop down menu) that has more values.
I suppose I would have to type the code in the main form to run this action.

'Private Sub Command_ADD_SAMPLE_Click ()

DoCmd.OpenForm "edit_SAMPLE", acNormal,,, acFormAdd, acDialog, "Add sample ...."

Me.Form '.Form & "edit_SAMPLE" & CB_ID_LOCATION.DefaultValue = 2

End Sub

But that code does not work

You got a better idea
 
Why not set DefaultValue property of combobox in design?
 
I know about that possibility

The idea is that a form of the same format and shapeis used to enter different patterns.

I do not want to work 8 forms and set each of them a default value

I want one form I'm running over 8 different buttons.
And in the code of each button i want to define the default value of that field (CB_ID_LOCATION)
 
Post your database with some sample data, zip it!
 
Well, don't use Me. unless code is the form you want to affect.

Forms!edit_SAMPLE.CB_ID_LOCATION.DefaultValue = 2

I prefer to have code in the form that code is affecting.
 
I want one form I'm running over 8 different buttons.
And in the code of each button i want to define the default value of that field (CB_ID_LOCATION)

Instead of setting a default value for the combobox, set a function.

In the function, check which button is the trigger that opens the form.
If button1, then Defaultvalue1
If Button2, then DefaultValue2

and so on.

You can use OpenArgs for recognizing the trigger button.
 
Sorry for waiting
I had to clean the base of different data
At the beginning, when the main shape is opened, clicking the button opens the auxiliary form.

But for each page (item type) "CBox_ID_LOCATION" must have another value.
The buttons have the name (CmdB_01, CmdB_02, CmdB_03, ...)

I hope you understand my problem
 

Attachments

Thanks for the ideas

but I am an ambitious beginner
which jumped to the end of the lesson
I do not have the knowledge
But I'm persistent.
I'm working with trial and error method
I like the idea with OpenArgs, but I do not know in whitch form I enter the procedure
 
Sorry can't open your database, seems to be corrupt - hopeful others have more luck.
 
Also unable to help.
I can open the database and the edit sample form but get an OLE server error with frm_MJESTO
 
I am from Croatia
Probably a problem in regional settings

I have solved this in the following way
 

Attachments

  • promjena regionalnih postavki sustava.jpg
    promjena regionalnih postavki sustava.jpg
    102.2 KB · Views: 79

Users who are viewing this thread

Back
Top Bottom