problem with Create Dblclick event at vb6 ListView - vb6

If one of the items in the list view is double-clicked,
I need to open a other form(psa33), looking for the column value of the double-clicked product.
The column value for that double-clicked item must appear entered in the newly opened form.
How can I make it?
help me plz
Private Sub ListView1_DblClick()
PSA33.Show
End Sub
now it works only form change but i need to do more.
i think i need to find listview1' s doubleclicked item's column data
and send it to psa33
but i dont know how to do it

The property ListView1.SelectedItem holds a reference to the selected ListItem.
Be sure to check if the property is pointing to a valid item because the user could also make a double click in the empty space of a ListView.
Example code:
If ListView1.SelectedItem Is Nothing Then
MsgBox "No tem selected", vbOKOnly + vbExclamation, "Can't proceed"
Else
PSA33.<NewPropertyYouHaveToCreate> = ListView2.SelectedItem.Text
PSA33.Show
End If

Related

Don't want to clear records on form

My Access form is for data entry of donations at my church. I don't want the form to clear for each new record. Some of the data will remain the same. Just want to change some fields and select "Add New Record"
Follow these steps :
Go to your form.
Switch to Design view
Select the desired control
Switch to the control's Event tab
In After Update Sleect the ... (3 dots) and choose Code Builder
Change the method to look like this :
Private Sub Name_AfterUpdate()
Me!Name.DefaultValue = """" & Me!Name.Value & """"
End Sub
My control in this code is Name, change that to your control's name
Close the code builder
Done!
You will have to do this for every field you want not to clear!

Selection in ListBox on an Excel worksheet goes blank everytime I do something, why?

So, I have an ActiveX ListBox control named ListBox1 on Sheet1 of my Excel Workbook. I enabled multiple selections on it.
I also put some code in the Sheet1 Object:
Private Sub ListBox1_Change()
Debug.Print "hello world"
End Sub
Now, if I select three values in my listbox, I see "Hello world" three times in my immediate window. So I guess the Change event triggers correctly.
When I select any cell on the same sheet where my listbox is, and I do something with it (e.g. I type "ABCDE" in it, or I press Delete) the selection I made in the listbox goes blank.
So if I had the first value in the list selected, and then I click cell "A1", type "Hello" in it and press Enter, the very moment I hit the key the first value is unselected from the listbox.
Why the hell is this? This is driving me crazy. Is the Listbox1_Change event not working properly?
It's funny though, because I don't see an extra "Hello world" in the immediate window, so I guess the event didn't actually trigger...
Any thought?
Bruder
As I mentioned earlier this is because the .Listfillrange for both the ListBox is resetting automatically.
You have specified a named range for your .Listfillrange and the formula for the named range is
For FiltroCliente
=IF(CollClientePicker<>1,OFFSET(DatiMaschera!$D$2,0,0,COUNTA(DatiMaschera!$D:$D)-1,1),"")
Now when you are making any change, Excel is re-calculating the named range because of which the .Listfillrange gets automatically updated.
Here is another way to check it.
Scroll your Listbox1 and select an item and then select an item in Listbox2. You will notice that the Listbox1 automatically scrolls to the top because it's .Listfillrange gets automatically updated.
SOLUTION
Instead of a Named Range in .Listfillrange, automatically fill the listbox using .Additem
SAMPLE CODE
'~~> Example : Add values from Cell A1:A10
For i = 1 To 10
ListBox1.AddItem Sheets("Sheet1").Range("A" & i).Value
Next i
HTH
Sid

The TextBox.text value is empty even though something has been entered

I am trying to debug a form window written in VB6. It is to enter customer data so you can type in an address in the address field. You can also type in something like 90210 Main Street and on enter it will automatically parse the text and write the 90210 in the postal code field below and let Main Street be in the address field. It however can occasionally parse it wrong, which is what I am trying to fix.
The problem is that I can't figure out how exactly it is set up. If I type something into the TextBox address field and do a
?ADDRESS.text
In the immediate window, the it returns an empty string. There is also only a single function defined when I look in the dropdown list under the form. But when I set a breakpoint at it and click the textbox, then it doesn't break. It is the GotFocus() event:
Private Sub ADDRESS_GotFocus()
Call GCui.BM(ADDRESS)
End Sub
It's the same with the POSTALCODE textbox. It has DblClick, GotFocus and LostFocus event functions defined. But setting a break point in either one of them has no effect.
Is there any way of finding out where in the form the value Main Street or 90210 is stored? They are clearly visible in the ADDRESS textbox and the POSTALCODE textbox, but the immediate window returns an empty line when asking for their values.
Update 1:
It seems that someone has decided to completely rebuild the form with new controls. It probably happens in form.load. But I would still like to know if there is a way to search through variable values to find the string "Main Street" or "90210".
Update 2:
It turns out that there are two frames on top of each other. The top frame is hidden at startup and the bottom (almost identical frame with same labels and controls) are shown.
You can use the "Watch" feature. This will let you inspect all the properties of a form and all controls within the form and their values (look at the controls node).
You can also do this via code by looping over the form.controls collection.
Dim o As Object
For Each o In Me.Controls
If TypeOf o Is TextBox Then
Debug.Print o.Text
End If
Next

Applescript populate a dialog list with Microsoft outlook contacts

All,
I'm attempting to create an applescript that allows me to create a word document (a business proposal). One part is being able to use applescript to select the client from micorsoft outlook.
I know how to do this in VBA but in Applescript I can't seem to figure it out. Basically I need a dialog box that either has a list of all my Outlook contacts from which I can select one.
Much appreciated,
-J
Quick and dirty, but this works (Office 2008)
tell application "Microsoft Entourage"
set contactList to {}
set lastContact to (count contacts)
repeat with thisContact from 1 to lastContact
set theContact to item thisContact of contacts
set end of contactList to (first name of theContact & " " & last name of theContact)
end repeat
set contactSelected to (choose from list contactList with prompt "Please select a contact." without multiple selections allowed) as text
if (contactSelected is not "False") then
display dialog contactSelected
end if
end tell
There are essentially two parts to the script: getting the contact names and presenting the information. Getting the contacts is easy because contacts is a property of the application itself. Running this in 40+ contacts only takes a second.
Presenting the data and getting the selection isn't so obvious. The data to be presented has to be a string. Honestly, I forget why I have as text dangling off the end, but I seem to remember that doing this was easier if everything was handled as a string of some kind. Once the selection has been verified—having "False" returned means the user clicked the cancel button—you are then able to carry on with the string where I placed the display dialog. Unfortunately, you don't get the row number or anything convenient like that. It just doesn't work that way, so you will have to do a bit of fudging to get back to the corresponding contact object itself.
Add salt to taste...

Performing Form Validation with an Access 2003 ADP project

I'm developing an Access 2003 Database that uses a MS SQLServer backend.
I'm trying to do Form Validation and am experiencing some problems.
ValidationRule for each field seems to be ignored
I can't figure out what event I should override to enforce validation without having the database do it. (I'm not against this, it's just unknown to me how I'd catch Error Messages, instead of displaying them to the user)
I've tried getting around number 2 by disallowing closing and enforcing the use of a "Close Button", but the user can side step it by pressing tab, or by pressing the "Next Record" button at the bottom.
Any suggestions would be greatly appreciated.
If you are using the validation rules property, you can catch validation and duplicate key errors, amongst other things, in the Form Error event:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr=2107 Then
MsgBox "Validation error! " & ActiveControl.Name
End If
End Sub
You can enforce the use of your close button with a variable defined at form level and set to false unless your button is clicked.
Option Compare Database
Option Explicit
Public AllowClose As Boolean
Private Sub Form_Load()
AllowClose = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = Not AllowClose
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
AllowClose = True
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
From: http://www.tek-tips.com/faqs.cfm?fid=2071
If you give us an example of one of your validation rules, it might help.
However, I've been under the habit of putting validation in Before Update (especially when I've got more complex validation algorithms)
Update:
I did some experimentation and it seems that the validation rule for the field is ONLY checked when you make an update to the field, but not if you are making an update somewhere else on the form, and not when you save the record. So I think your solution is to move validation to Form_BeforeUpdate.
OR you could make the column in the table non-null - which would force the users do something with the field.
OR, if the field must be "Testing", then you could side step the whole thing by setting a default value and locking the field so the user can't change it.
You can hide the navigation buttons by setting the form's Navigation Buttons property to "No." You can also disallow tabbing to a new record by setting the form's Cycle property to "Current Record."
With any nontrival application interface in Access, I usually lock the form down pretty tight and supply my own nav buttons, close button, etc. as needed.

Resources