[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Giving a Form a Unique ID

Posted on 2006-06-22
8
Medium Priority
?
228 Views
Last Modified: 2008-02-26
Hey Experts

I am making POS Software and I need to give each transaction form and unique id

I tried

Private Sub CmdSaleToClient_Click()

Dim frm As New frmSaleToClient

Transcode = Transcode + 1

frm.Caption = Transcode

frm.Show

End Sub

But it does not work when you get to the main bill screen

The problem is if you open say 5 transactions it opens five form each with a different transaction ID but if I go to transaction form 1 and go to the main bill screen the transaction id changes to 5.

Please Help

Nothern_Lights
0
Comment
Question by:Nothern_Lights
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 16959085
Hi Nothern_Lights,

Is this an MDI application or an SDI application? The key really to either is to determine exactly what happens, you have the relevant transcode in each form's caption so this is what you could use. Personally I would store this in the form's .Tag property but caption is fine.

It depends on how you activate the main form from each transaction, you may be able to set a property in the main form from the last activated transaction form for example.

Tim Cottee
0
 

Author Comment

by:Nothern_Lights
ID: 16959390
Hey Tim

What is the difference between MDI and SDI application?

In the frmSaleToClient properties I have in the caption "Sale To Client"

And I use code to change the form caption to the transaction ID but when I read the form caption I get “Sale To Client” but on the screen is has the Transaction ID

I tried storing the Transaction ID in the Form Tag but i still got the same problem for so weird reason

Thanks

Nothern_Lights
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 16959419
Nothern_Lights,

Firstly, MDI - multiple document interface, where you have a parent form and child forms are contained and constrained within it. SDI - Single Document Interface, here you can still have multiple forms but they are effectively only constrained by the desktop. Word and excel are good examples of an MDI interface, though these days you can make them work in a pseudo-SDI way as well.

The reason you still get "Sale To Client" I would expect is that you are not referencing the form you think you are. Because you are creating new instances of the same base form, if you refer to "frmSaleToClient.Caption" it will actually open a hidden instance of the base form and that is the one you are probably getting the information from. You could probably use ActiveForm.Caption / ActiveForm.Tag to determine which form you are currently referring to. This will work excellently in an MDI interface but perhaps not so well in SDI.

Tim
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:inthedark
ID: 16959428
MDI - Multiple Document Interface
SDI - Single Document Interface
0
 
LVL 17

Expert Comment

by:inthedark
ID: 16959471
See solution here.
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21891753.html

I think that by declaring the form with the new keyword the form load event fires first before the current sub executes.


Dim frm As New frmSaleToClient

Change to:

Dim frm As frmSaleToClient
set frm = New frmSaleToClient


0
 

Author Comment

by:Nothern_Lights
ID: 16959543
Tim

I can only get ActiveForm.Caption / ActiveForm.Tag to work using MDI form

I would prefer to not to use MDI use SDI instead

Thanks

Nothern_Lights
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 1500 total points
ID: 16959579
Nothern_Lights,

So what you have to do in that situation then is to update a property on your main form each time you activate one of your transaction forms. Something like:

In Main Form:

Private _CurrentTransaction As Integer


Public Property Let CurrentTransaction(ByVal TransactionNumber As Integer)
    _CurrentTransaction = TransactionNumber
End Property

Public Property Get CurrentTransaction() As Integer
    CurrentTransaction = _CurrentTransaction
End Property

This will allow your other forms to set this property so that you can use it in the main form.

Then in the frmSaleToClient form have:

Private Sub Form_Activate()
    MainForm.CurrentTransaction = Me.Tag
End Sub

So whenever you click on one of the transaction forms, the property in your main form will be set to the value of that transaction form's .Tag property. This way your main form can know which was the last selected transaction form.

Tim
0
 

Author Comment

by:Nothern_Lights
ID: 16961853
Thanks For All your Help Tim

Nothern_Lights
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question