Don't want to clear records on form - ms-access-2013

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!

Related

problem with Create Dblclick event at vb6 ListView

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

A2019: how to get a context menu in a form for an unbound date control like for bound date controls

I'm not sure how it is possible to get the same contextmenu for an unbound form's control like for bound controls, both with a date value.
There are two unbound controls which get their control value via:
txtErsteSpende:
=Wenn([spSurrKey]>0;DomMin("[zaZahlDatum]";"[tblZahlungen]";"[zaSP_FKEY] = " & [Formulare]![frm110_Spender]![spSurrKey]);Null)
and
txtLetzteSpende:
=Wenn([spSurrKey]>0;DomMax("[zaZahlDatum]";"[tblZahlungen]";"[zaSP_FKEY] = " & [Formulare]![frm110_Spender]![spSurrKey]);Null)
Sorry for these are examples in german: "wenn" means "iif". It seems the bound control allows the context menu but not available for unbound controls.
Or is there a technique without writing vba-code to allow same context menu for both kind of controls?
Any suggestions appreciated
thx
Contextmenu filter a date - bound control
Contextmenu filter a date - unbound control
the goal was:
make the form updatable
display the date contextmenu for the two textboxes
After trying around with subforms which wasn't practable because the form is displayed in data sheet view I found this solution:
qry110:
SELECT tblSpender.spID, tblSpender.spNachname, tblSpender.spVorname, tblSpender.spOrt, tblSpender.spGebdat, DMin("[zaZahlungsdatum]","[tblZahlungen]","[zaSPFKEY] = " & Nz([tblSpender].[spID],0)) AS datErsteSpende, DMax("[zaZahlungsdatum]","[tblZahlungen]","[zaSPFKEY] = " & Nz([tblSpender].[spID],0)) AS datLetzteSpende
FROM tblSpender;
=> works fine but shows #Error in the form's textbox when in table tblZahlungen there is no entry (no ForeignKey) for the PrimaryKey in tblSpender
So I created a second query as recordsource for frm110 based on the first qry110 which checks the NULLvalue:
qry111:
SELECT qry110_Spender.spID, qry110_Spender.spNachname, qry110_Spender.spVorname, qry110_Spender.spOrt, qry110_Spender.spGebdat, IIf(Nz([datErsteSpende],0)>0,DateValue([datErsteSpende]),Null) AS datumErsteSpende, IIf(Nz([datLetzteSpende],0)>0,DateValue([datLetzteSpende]),Null) AS datumLetzteSpende
FROM qry110_Spender;
It works and now the form's recordset IS updatable.
Maybe the form isn't very performant for big data but it's acceptable for my users
thx for your hints
contextmenu for date textboxes

How to click on Web Table column's Web Button in following case?

I have one web table, in this I want to delete particular record by clicking on record's delete button.
I got the value of row but I am not able to perform click on web button of particular row and also there is 2 buttons in one column.
How to click on delete icon of particular row?
You need to set a reference to the item within the specific row and then click on it - something like this:
Set oLink = Browser("myBrowser").Page("myPage").WebTable("myTable").ChildItem(iRow,8,"Link",0)
oLink.Click
You will potentially need to amend the "Link" and the number 8 in your own code. iRow represents the row you are trying to interact with.
Essentially what this code does is set an object reference to the first item of type "Link", in column 8 of the table, then uses a Click event to select it. If your delete icon is a WebButton, then replace "Link" with "WebButton" for example. The final 0 in the command tells UFT to select the first element matching the object type - you might need 1 if your two icons are in the same column of the table.
Let me know if that helped.

Gridview Edit - Redirect to Update Form

I really need some help..! I have several forms & several reports in a windows (.aspx) app that I created. The forms have an option to pull data from an outside db, once done, they can edit the form & then click the submit button to save to 1 of the 5 tables I created in SQL. My problem is, we are getting a bunch of duplicate records. There should be 1 row of data (record) per call #.
I have searched & searched & what I found to be the best (with consideration of the user's needs) is if I could have the 'edit' button in the report gridview to redirect to the form page (already created as an input form), only have a couple items changed (such as instead of the submit, to hid that button & enable a 'update' button, IN ADDITION to the form prepopulating with the data (IF any) that's in the table corresponding with that form & report. Although I have created several applications, I am new to hard coding & so 'detailed' guidance is requested. I will GREATLY appreciate any help! This application needs deployed asap so I am really stressing on this one..
Needing Help Desperately..
Kathy
It's actually better to use select and here's why:
Protected Sub MyGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles MyGridView.SelectedIndexChanged
Dim formid As String = gvRequisitonLines.DataKeys(gvRequisitonLines.SelectedRow).Value.ToString()
Reponse.Redirect("~/FormPage.aspx?formid=" & formid)
End Sub
This allows you to get the selected index extremely easily and use it to get the DataKey which you can send as a QueryString parameter to your form page.
Of course this requires that you have your form identifier set as a datakey on the GridView.
So for clarity, your button would have the text "Edit" but the command "Select".

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

Resources