[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Giving a Form a Unique ID

Posted on 2006-06-22
8
Medium Priority
?
230 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

834 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