Solved

Giving a Form a Unique ID

Posted on 2006-06-22
8
222 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

856 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