Is it possible requery a form open with Docmd.openform "nameform",,,,acformAdd? - ms-access-2010

I'm facing with a form and I need to know if possible to use - Me.requery- method on a Form that i've opened with
Docmd.openform "nameform",acNormal,,,acformAdd.
In other words my Dbase have Form_A and table_A. I can scroll and edit records using Form A.
When I need to insert a new record I use the method :
DoCmd.OpenForm "Form_A", acNormal, , , acFormAdd
emphasized text**emphasized text
and insert the new record.
The question is:
How can I scroll all recordset without close and reopen the form? is't possible requery the form_A directly .
Many thanks to all

You open the form to add records only:
DoCmd.OpenForm "Form_A", acNormal, , , acFormAdd
Don't do that:
DoCmd.OpenForm "Form_A"

I solved the problem with a workaround :
Private Sub cmdnewprogetto_Click()
Application.Echo False
DoCmd.OpenForm "Frm_A", acNormal
DoCmd.GoToRecord acDataForm, "Frm_A", acNewRec
Application.Echo True
End sub

Related

MS Access requery form after group delete

Access 2010 & Access backend.
I use a Delete query to delete a select group of items on a
continuous form.
The Delete query is in the form_delete event and
it works.
in the form_AfterDelConfirm event I have a me.requery command but the form is not requeried because in the form_delete I have Cancel = True which prevents the AfterDelConfirm event from firing. If i change the Cancel to False the AfterDelConfirm fires but the me.requery produces an error that the record is in use by another user (I am the only user).
The problem is that the continuous form displays #Deleted
in the deleted records of the deleted group items.
I also have a requery button that requeries the subform which clears the deleted items.
My goal is to have the deleted items clear without the user having to click the requery button.
How can I accomplish this?
Thanks,
Skip the delete query. Instead, delete directly from the form using its recordset in the code you call from the button click:
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
While Not rs.EOF
' Specify conditions for a delete, for example:
If rs!FieldA.Value = SomeNumber And rs!FieldB.Value = "SomeText" Then
rs.Delete
End If
rs.MoveNext
Wend
Set rs = Nothing
No requery of the form will be needed.

Memo Username and Date stamp

I am new to Access and programing codes. I am building a data base where daily notes for issues can be kept. I want the end user to be able to view past records and make updates. However I do not want the to alter text previously put in the memo field containing the issue they are wanting to update. Also I am wanting to flag there new input with username and date/time.
I am try to accomplish this by inserting the following code into the AfterUpdate()
Private Sub Text0_AfterUpdate()
Me.Text0 = Me.Text0.Value & " " & UserName() & " # " & Now()
End Sub
I used Text0 because I am testing this code. Anyway this works in an unbound text box perfectly for flagging the new input. However when I try using this in my form with bound textboxes it fails to work. Any ideas? If I get this working I want to find a way to prevent editing on previously entered text but that is not a must.
The form containing the memo textbox for update was corrupt. By copying and pasting to create a new form with everything but the textbox I was having problems with I fixed my problem. I just made a new text box in the new form.

jqGrid - multiselect rows and rowselect

I have a jqGrid with multi select set to true using the asp.net jqGrid.
I want it to select multipole rows then click a button and something will apply to the IDs for all those rows. At the same time, clicking on a row should populate some fields (ex. textboxes). The problem is I've used the rowselect method and although that allows me to populate the form on row select it does not allow me to select multiple checkbox rows.
Is there a way to make the checkboxes not activate the rowselect method?
OR is the alternative to create a hyperlink on the result of the value in a cell that calls a method in code behind passing the ID? Is my last idea even possible?
Thanks
In order for checkboxes not to activate the rowselect event , you can use cellselect instead of rowselect function. Under cellselect function , check for column index if its not the checkbox column , then execute the code which you have written for rowselect.
You may need to write client side code [javascript] , you can add
tag [server] and add cellselect option to it . For more information check the link below
http://www.trirand.net/forum/default.aspx?g=posts&t=1452

Reading a DataSet in JavaScript

' USED TO REFRESH THE PAGE WHIN IT IS POSTED BACK
If (IsPostBack = False) Then
' USED TO DISPLAY DEFAULT FIRST ITEM IN THE DROPDOWN
Dim Li1 As New ListItem()
Li1.Text = "ALL"
Li1.Value = ""
cboStudy.Items.Add(Li1)
' USED TO COUNT THE STUDIES IN THE DROPDOWN
If (objDS.Tables(0).Rows.Count <> 0) Then
' USED TO CIRCULATE LOOP UPTO THE RECORD COUNT
Dim i As Integer
For i = 0 To objDS.Tables(0).Rows.Count - 1
' USED TO CREATE NEW ITEM IN THE DROPDOWN
Dim Li As New ListItem
Li.Text = objDS.Tables(0).Rows(i)("Study_Desc").ToString()
Li.Value = objDS.Tables(0).Rows(i)("Study_ID").ToString()
'USED TO ADD ITEMS IN THE DROPDOWN
cboStudy.Items.Add(Li)
Next
End If
'USED TO SAVE THE CHANGES IN DATASET
objDS.AcceptChanges()
' USED TO CLOSE THE DATABASE CONNECTION
objDS.Dispose()
End If
End If
I have to read dataset in javascript. So that I have to bind Study_Desc in DropDownList.
How can I do that?
I believe you might find it useful to review how an ASP.NET page works and how it renders. In your particular case you are setting the contents of a dropdownlist to your dataset. This will then render a 'select' object to the user with the appropriate entries without the need for Javascript. This all occurs on the server-side, which is processed on the server before a HTML response to given back to the user.
With Javascript, this code runs on the client-side, i.e. the user's computer. Here it is possible to retreive your dataset (by this, the dataset will get serialised to be passed over the wire and read into a format that Javascript can read) and have it interact on the client-side. The question is, in your case, is why bother as you're rendering the dropdown on the server-side. If you are interested in pushing your dataset to Javascript, check out the links on this post for a selection of approaches you can take.
Minor notes:
In your code you're using the 'AcceptChanges' method when there is absolutely no reason to use this unless you're making a change(s) to the dataset which I'm guessing you're not in the PageLoad...

Insert record with EmptyDataTemplate in asp:ListView

I have an EmptyDataTemplate in my asp:ListView which I want to use to insert a new record.
I have Inserting working in the InsertItemTemplate... I thought I could copy the InsertItemTemplate into the EmptyDataTemplate, on clicking Insert this gives the error
Insert can only be called on an insert item. Ensure only the InsertTemplate has a button with CommandName=Insert.
How can I use the EmptyDataTemplate to Insert a row? Do I need to use the OnClick of the button to access the values within the EmptyDataTemplate and do an Insert by myself?
I'm using LinqDataSource
You might have figured it by now
but if you set the InsertItemPosition to anything other than None the EmptyData Template will not be rendered i.e it will always show the insert template
you can read more here
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.emptydatatemplate.aspx
No way if want to insert data in empty data template.
It is possible to do an insert from the EmptyDataTemplate by handcrafting the insert. I am using a listview to display a static number of rows based on a unique filtered item. I am basically listing all the static attributes of an object. In the case where a new object is filtered on that does not have any attributes associated with it, i use the EmptyDataTemplate of the listview to display a HTMLTable that contains asp.net controls to capture data. I have a command button within the table that i evaluate using the ListView_ItemCommand. If the CommandName matches that of the "Insert" button within the EmptyDataItem, I use the ListView.Controls(0).FindControl method to locate my table. I then loop through my table and do inserts on the data found within each row. I included the how to find a control within the htmltable. In my code I am actually grabbing a bunch of controls then crafting the sql and using a SQLConnection to perform the insert.
Protected Sub ListView_ItemCommand(sender As Object, e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView.ItemCommand
Select Case e.CommandName
Case "Submit"
Dim edt As HtmlTable = ListView.Controls(0).FindControl("myhtmltable")
Dim ddl As DropDownList = CType(edt.FindControl("mydropdownlist"), DropDownList)
'Perform Insert
Case "Some other commandname"
End Select
End Sub
You will need to still do error checking and databind() and refresh your listview.
Is this the best way. Maybe not... But it is possible.
~Ian

Resources