Solved

Giving a Form a Unique ID

Posted on 2006-06-22
8
221 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
 
LVL 17

Expert Comment

by:inthedark
ID: 16959428
MDI - Multiple Document Interface
SDI - Single Document Interface
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
String manipulation in Visual Basic 7 58
Search combo error "Data Type Mismatch in Criteria Expression" 2 49
TT Auto Dashboard 13 79
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now