Kamis, 26 Mei 2011

RE: [MS_AccessPros] Reposition Cursor to exact record

 

Abdul-

If frmSalesOrder is already open, you need to Requery that form - not frmSalesQuote. Then use the recordset of frmSalesOrder to find the record you just added.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Abdul Shakeel
Sent: Thursday, May 26, 2011 9:35 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Reposition Cursor to exact record

Dear John

I don't want to open frmSalesOrder, let me explain you, I have form frmSalesQuote on which I have command button which runs the following code to update frmSalesOrder, after I run this code frmSalesQuote required and showing the first record, however I want that it still remain on the record which was updated the record in frmSalesOrder

Thanks & Regards,
--
Abdul Shakeel

________________________________
From: John Viescas <john@viescas.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Thursday, May 26, 2011 11:21 AM
Subject: RE: [MS_AccessPros] Reposition Cursor to exact record

Abdul-

It looks like your code is inserting new data into tblSalesOrders and
tblSalesOrderDetails, but your current form is editing sales quotes. You have
saved the ID of the new sales order, so you could do something like:

DoCmd.OpenForm "frmSalesOrder", WhereCondition:="SalesOrderID = " & lngOrderID

.. to open the sales order form to display the data you just created.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Abdul Shakeel
Sent: Wednesday, May 25, 2011 8:52 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Reposition Cursor to exact record

I am using the following code to update my form base on existing form record

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim strSql As String
Dim lngOrderID As Long


If IsNull(Me.CustomerCode) Or IsNull(Me.QuotationNo) Or
IsNull(Me.QuotationDate) Or IsNull(Me.EmpID) Or Not SalesQuoteContainLines()
Then
MsgBox "Please Complete Quotation before Applied to Sales Order.",
vbInformation, "Sales Order Not Completed"
Exit Sub

ElseIf MsgBox("Are you sure you want to Apply this Quotation to Sales Order?
" & vbCrLf & _
"Kindly note that, Once you apply this Quote to Sales Order,"
& _
"it can not be edited, delete or undo.", vbYesNo +
vbInformation, "Applied to Sales Order") = vbYes Then

Me!StatusID = Applied_To_Sales_Order

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblSalesOrders", dbOpenDynaset)
Set rs1 = db.OpenRecordset("tblSalesOrderDetails", dbOpenDynaset)
Set rs2 = Me.SalesQuotesSubform.Form.Recordset

rs.AddNew
rs!CustomerCode = Me.CustomerCode
rs!EmpID = Me.EmpID
rs!SalesOrderNo = "QUO - " & Me.QuotationNo
rs!SalesOrderDate = Me.QuotationDate
rs!Freight = Me.Freight
rs!Tax = Me.Tax
lngOrderID = rs!SalesOrderID
rs.Update

rs2.MoveFirst
Do While Not rs2.EOF
rs1.AddNew
rs1!SalesOrderID = lngOrderID
rs1!SoLineNumber = rs2!sqOrderLineNumber
rs1!InventoryCode = rs2!InventoryCode
rs1!Quantity = rs2!Quantity
rs1!Discount = rs2!Discount
rs1!Rate = rs2!Rate
rs1.Update
rs2.MoveNext

Loop

rs.Close
rs1.Close
db.Close

Set rs = Nothing
Set rs1 = Nothing
Set db = Nothing

MsgBox "Sales Order Number Assigned: " & "QUO - " & Me.QuotationNo,
vbInformation, "Applying To Sales Order"

Else
Me.Undo
End If

Me.Requery

how do I reposition to the exact record which is being update, because Requery
gets me to the first record I have tried after requery something like that but
no luck
Set rs = Me.RecordsetClone
rs.FindFirst "SalesQuoteID =" & Me.SalesQuoteID
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing

Thanks & Regards,
--
Abdul Shakeel

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar