Instance Of Same Form (1 Viewer)

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
I have a form for entering an invoice, but in a very professional way
But what I want is to open this form multiple times at the same time
This form contains Subform. When I Create multiple instances of a form, it is inserted in the same Subform. Is there a solution to this problem?
In addition, when saving the invoice, I call a query that is very complex and cannot be done on the Vba code, and this query is linked to the Form name
How do I solve this problem
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
In addition, when opening the form automatically, add about 5,000 blank records to the subform so that the user can add inside it so that he does not need to add a new record when adding information.

Of course, when saving the invoice, it insert only the full records on the main table
 

Attachments

  • Untitled.png
    Untitled.png
    48.2 KB · Views: 73

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
This form contains Subform. When I Create multiple instances of a form, it is inserted in the same Subform. Is there a solution to this problem?
1. Can you clarify this? As written it does not make sense. What do you mean by 'it is inserted in the same subform"?
Each form instance has it own subform instance
2. In addition, when saving the invoice, I call a query that is very complex and cannot be done on the Vba code, and this query is linked to the Form name
You can have a complex query, but you need to pass the value in as a parameter. You cannot have the query reference a form name. Each instance has the same name
add about 5,000 blank records to the subform
3. That sounds like a truly horrible idea.
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
Ok, as for the sub-form, it is linked to a table and of course when you open another form of the form it inserts the records into the same sub-form that is attached to the table
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
OK is the same parameter, but how does the parameter know from which interface to take the value?
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
No, it is not possible to add 5000 records at the same time, but this form is designed so that the user does not add a new record every time he wants to add information
As if he was adding in a textbox
when saving the invoice, it insert only not null records to the main table
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
When opening the form on the method of opening multiple instances of a form
When you open the query, it does not recognize the form name
 

Attachments

  • Untitled2.png
    Untitled2.png
    47.4 KB · Views: 66

Gasman

Enthusiastic Amateur
Local time
Today, 22:15
Joined
Sep 21, 2011
Messages
14,238
All I can do is give you the mechanism to do it, via that link.
Why you want/need multiple instances of a form that could hold 5000 new records is way beyond my understanding.? :unsure:

I entered over 20K records into one of my DBs, and I just tabbed though to the next record.? hardly an issue?
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
Ok because this Form is for entering invoices
It can itself be sales
Or sales return
Or purchases...
Therefore, I will need to open the same form more than once at the same time
And I have a purpose of being on the same form
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:15
Joined
Sep 21, 2011
Messages
14,238
When opening the form on the method of opening multiple instances of a form
When you open the query, it does not recognize the form name
So do not hard code form names in the query?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
In addition, when saving the invoice, I call a query that is very complex and cannot be done on the Vba code, and this query is linked to the Form name
How do I solve this problem
As I have already stated, get rid of any form names in the query. You will have to pass those values to the querydef each time you have the invoice through the calling form. Can you post the query? Even if this query is really complex you still may be able to do this in code easily by calling the saved query def.
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
Indeed, it is so complicated that I cannot make it again :ROFLMAO: ,This is related to the invoice accounting entry
But the idea of sending the form name every time I request a query is pretty
How can I find out the name of each form that I open
How can I pass it to the parameter in query
 

Attachments

  • Untitled3.png
    Untitled3.png
    104.1 KB · Views: 79

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
Wow! I am not sure where to start. If you have a query like that, you have way bigger problems IMO. Instead of an Image copy that query and post it as if you where posting code. Use the </> to do that. There has to be a much, much, much easier way to do what you are doing. Your data is either far from normalized or you need some additional tables.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
In the worst case you would replace all form references with generic parameters. Could be done in Word using find and replace. Then you pass in the value to the query definition.
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
Yes, I will choose the second solution, but how do, I do not know about query definition
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
Assume you replace all those form references with paramets
p1,p2,p3.....
You would have to pass in the parameter values before using the query or every time you requery. This will work even with form instances. Basically each instance has to update the query def before using the query
Code:
 dim
 With db.QueryDefs("YourQueryName')
        .Parameters(0) = Me!some value
        .Parameters(1) = Me!somevalue2
        ....
        .Parameters(n) = Me!somevaluen
 End With
You could also replace the forms reference with TempVars. Then set the value of tempvars. This may be easier.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:15
Joined
May 21, 2018
Messages
8,525
But seriously, I think you are totally wasting your time until fixing that query and the underlying issue.
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
I will try to work with this code
Trust me, there is no solution. I am sure because every number I used cannot be used <> because they are separate numbers
 

HASAN-1993

Member
Local time
Tomorrow, 00:15
Joined
Jan 22, 2021
Messages
89
Ok now this problem has been solved
But the problem remained the subform
How can each new instance have a separate table
 

Users who are viewing this thread

Top Bottom