Form With VB Code

May 10, 2005

hey can anyone please explain how to adjust the below code to open the specific order ID that has been double clicked? At the moment no matter which order is double clicked the same order is opened.

Private Sub OrderID_DblClick(Cancel As Integer)
On Error GoTo Err_OrderID_DblClick

Dim stDocName As String
stDocName = "Orders"
DoCmd.OpenForm stDocName



Exit_OrderID_DblClick:
Exit Sub

Err_OrderID_DblClick:
MsgBox Err.Description
Resume Exit_OrderID_DblClick


End Sub

Thanks in advance.

View Replies


ADVERTISEMENT

Forms :: How To Use Data On A Form When Running Code Before Closing The Form

Feb 4, 2014

I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.

When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).

Is there a way to trap Data on form just before the form closes?

View 4 Replies View Related

Need Code To Open TeacherDetailFrm Form Main Form.

Jun 11, 2007

Hi
I need code to open TeacherDetailFrm form Main form.

I have TeacherStudentSubFr*m on the Mainform, FirstNameTxt on the TeacherStudentSubFr*m, and TeacherDetailFrm.
I need code to open the TeacherDetailFrm By double click on the FirstNameTxt.

I use this code but no data come and query dialog box come.

Private Sub FirstNameTxt_DblCli*ck(Cancel As Integer)
Dim DocSubForm As String
Dim DocText As String
DocSubForm = "TeacherDetailFrm"
'DocText = "[Result]=" & "'" & Me![result] & "'"
DoCmd.OpenForm DocSubForm, , , "[ FirstNameFld ]=forms![TeacherStudentSubFrm]![ FirstNameTxt]"

End Sub


I like to upload the file but no way in this forum

View 2 Replies View Related

Search Code Work On One Form But Not The Other Form?

Jul 18, 2015

* This code works to search frmMember for criteria found in tblMember:

Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

[Code] ....

* But this next code which I have copied and Pasted to frmEventInput, then renamed the frm and tbl, retrieves the same criteria as the above (tblMember) instead of the tblEventInfo...

Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."

[code]...

What am I missing?

View 3 Replies View Related

Need Help With Code Behind Form

Feb 20, 2006

I have a db that has only 1 table and 1 form (picker db). That is because we only use it to gather info from pickers and dont want them to be able to do anything but enter data. I have a master db that is used by Managers to import data from pickers db to master db to run reports.

Problem is we have someone that is an Access wannabe and sometimes messes with the code behind the form. The only way they can get behind the form is F11 key. I am afraid that if I take off that option then I cant get into the form myself...

Is there some other way that I can set this up in startup and have a way to get into the design view if I need to?

You can tell that I am a new user :)
Thanks, Noreene

View 2 Replies View Related

VBA Code For A Form

Jan 5, 2006

on a form, i want to edit some vba code

how do i type vba code to add days to todays date

for example, if the [company name] field on the form is one thing, then the vba code should calculate 14 days after todays date, and output it in the [return date] field on the form
but if the [company name] field is somthing else, the vba code should calculate 30 days after todays date and output it on the [return date] field

here is my code right now

Private Sub Return_Date BeforeUpdate(Cancel As Integer)

Select Case Form![Company Name]
Case "CTI/Charlotte", "CTI/Chicago"
Form![return date] = DateAdd("d", 14, [return date])
Case Else
Form![return date] = DateAdd("d", 30, [return date])
End Select
End Sub

im sure this is easy to do, but im new to vba. i have to be able to do this in vba.

View 6 Replies View Related

Code For Rename Form

May 24, 2005

On the form On load event I have code verifying if a condition is true or not. If the condition is true, it does some things, now I want also to rename a form if the condition is true. So, I have created a macro to do this. But if I open the DB for second, third.... time and the condition is still true the macro can't find the specifyed form and brings up an error message wich gives to user the possibility to Debug. This way he has access to the code , and I don't want this to hapen.
Can I do this by using code and keeping the user away from code?
Thanks,
Attila

View 2 Replies View Related

Post-code On Form

Jan 23, 2008

Hallo,

I have a post code field on my form. What I want to do is, if a user enters a wrong code ... i,.e., not Post code format it alerts the user of post-code not in use. Please if there is any example of a database of this functionality usage or a way of doing it will be much appreciated.

I live in UK and the post codes down here are like E12 5AH ....

Many thanks

View 1 Replies View Related

Code Snippet On Form...help Me

Feb 22, 2005

hai

Im novice to access db, started couple of days before on urgent requirement .
the functionality part is , i need to create a form to interact with databse and get the necessary output .

Dim dbsExample As Database
Dim rstExample As Recordset
Dim fldExample As Field
Dim str As String
//
Private Sub Command4_Click()
Set dbsExample = OpenDatabase("db1.mdb")
str = "type_ur_id.Text"
rstExample = dbsExample.OpenRecordset("select * from xxx where ID=str")
If (!rstExample.EOF) Then
Text0.Text = rstExample(1)
Recordset.Close
End If
End Sub
//
on running this form , error is INVALID USE OF PROPERTY >

rstExample(1) retreives the ID column value. .

could anyof u suggest where the problem could be,,and give me an alternate code..

with regards
rhuy.

View 3 Replies View Related

Form Code Not Working

Aug 1, 2005

Maybe this should be posted under VBA.... not sure. Havent seen answer that works yet.
Its a form with an option group "PickWO" When you pick an option, different fieilds become visible-non visible. I created a field "PickWOvalue" to store the option value "1" or "2". That part works fine.(visible) The problem is when you reopen the form to view the records the option box value does not show or change the fields visible properties. And the on open cuauses an error. Anyone see the problem?




Private Sub Form_Open(Cancel As Integer)
Me.PickWOvalue.Value = Me.PickWO.Value
End Sub
`````````````````````````````````````
Private Sub PickWO_AfterUpdate()

Call NotVisible

Select Case Me.PickWO

Case Is = 1
Me.ReInspectionDate.Visible = True
Me.Price.Visible = False
Me.WOPreview.Visible = True
Me.PrtWO.Visible = True
Me.WBMInvoice_.Visible = False

Case Is = 2
Me.ReInspectionDate.Visible = False
Me.Price.Visible = True
Me.cmdPreTag.Visible = True
Me.cmdPrtTag.Visible = True
Me.WBMInvoice_.Visible = True


End Select

End Sub

View 6 Replies View Related

VB Code Help On An Access Form....

May 10, 2006

I've got 2 sub forms that I intend on using via a toggle button from my primary form to access them. Is there anyone that can give me a heads up on creating vb code that when OnOpen it will automatically advance to a new record for data entry? I want the form to keep anyone from accidentally changing existing info in that regard. I'm still really new with VB.

Thanks for any help,

Trey

View 1 Replies View Related

Code On Current On A Form

Jun 27, 2006

i have a subform within a form that i want to create and automated procedure.
the subform has a couple of combo boxes.

upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2
i am just having a hard time putting it in code.

as of now i have a on current event on the subform that reads

if me.[combobox1] like "b*" then
me.[combobox3] = me.[combobox2]*.05
end if

any help would be greatly appreciated!

View 1 Replies View Related

Code On Current On A Form

Jun 27, 2006

i have a subform within a form that i want to create and automated procedure.
the subform has a couple of combo boxes.

upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2
i am just having a hard time putting it in code.

as of now i have a on current event on the subform that reads

if me.[combobox1] like "b*" then
me.[combobox3] = me.[combobox2]*.05
end if

any help would be greatly appreciated!

View 1 Replies View Related

Code On Current On A Form

Jun 27, 2006

i have a subform within a form that i want to create and automated procedure.
the subform has a couple of combo boxes.

upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2
i am just having a hard time putting it in code.

as of now i have a on current event on the subform that reads

if me.[combobox1] like "b*" then
me.[combobox3] = me.[combobox2]*.05
end if

any help would be greatly appreciated!

View 1 Replies View Related

Urgent Help With Form Code Please

Sep 12, 2004

ok what follows is a kind of pseudocode of what I'm trying to do. It would really help if someone could tell me how to get a command button to do the following startin by the copying of fields into a new record in a table and then using that table to do the required actions. Any help would be greatly appreciated and yes it is urgent as the assignment is due in on Wednesday.

Copy fields into new record in table Transactions
If [Transaction.In or Out] = In Then

[Items.Current Qty] (for specified Part No.) = [Items.Current Qty] + [Transaction.Qty]

(Add new record to Purchase Orders Table)

[Purchase Orders.Purchase Order No] = [Transaction.From/To]

[Purchase Orders.Part No] = [Transaction.Part No]

End If

If [Transaction.In or Out] = Out Then

[Items.Current Qty] = [Items.Current Qty] – [Transaction.Qty]

(Add new record to Sales Orders)

[Sales Orders.Part No] = [Transaction.Part No.]

[Sales Orders.Sales Order No.] = [Transaction.From/To]

End If

View 1 Replies View Related

Bad Code In Form Filter

Mar 15, 2005

I found some code that lets me Filter a Report from a Popup Form. It uses 6 combo boxes with each box filtering my VehicleRecords table to the record I am looking for. The code for this can be found here: http://support.microsoft.com/kb/q208529
I modified just a few lines so that it would point to my VehicleRecords table.

When I enter information into any one of the combo boxes I get a Run Time Error 13 - Type Mismatch, and then I am pointed to this section of code.

What is wrong with this code?

Code: strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & "" _ And ""

View 3 Replies View Related

VB Code To Load A Form

Mar 14, 2006

Hi Guys

How do I load a form from another form? I would prefer to use VB (in fact, its probably the only way you can do it!). I have tried varius commands that would have worked in VB - but dont work in Access, like...

Code:Unload MeLoad Form_tblClientsForm_tblClients.show

The above code does not work AT ALL. It gets an error at the Unload Me line, an error at the Load Form_tblClients line, and the action 'Show' does not even exist under Form_tblClients, so that wont work either!

I am aware of Switchborads, but i want to know how to load a form, and make it pop up in a new window from within another form.

View 3 Replies View Related

Code Refeerencing From One Form To Another

Apr 4, 2006

The scenario: I have a command button on one form (cmdPatinient on frmData) . This command button opens a form (frmAssessment).
On this form I have a check box option (yes/no). (chkAnswer) If the checkbox is ticked (to indicate data entry is complete) then I want the command button on the other form to be disabled.


So, do I put the code on the On Click event of the form with the checkbox and then how do I reference the other form?

View 1 Replies View Related

Help In Access Form Code

Apr 5, 2007

Hi,

I have a form in access database. On click of a button I want to perform update process for records in a table "abc" in the same database. I have written the following code in the onclick function,

Code: Dim rs As New ADODB.Recordset Dim rsCount As New ADODB.Recordset Dim CntVal As Integer Dim con As New ADODB.Connection con.Provider = "microsoft.jet.oledb.4.0" con.Mode = adModeShareExclusive con.Open ("C: est.mdb") rs.Open "Select * from abc" Do While Not rs.EOF rsCount.Open "select count(test) from abc where test = '" & rs.Fields("test") & "'" If Not rsCount.EOF Then CntVal = rsCount.Fields(0).Value Else CntVal = 0 End If rsCount.Close con.Execute "Update abc set testcount = '" & CntVal & "' where ID1 = '" & rs.Fields("ID1").value & "'" Loop

In the above code, I am not able to use the command,
con.Open (App.Path & " est.mdb"). It gives "Object Required Error". And while opening the con object I get the error "You attempted to open a database that is already opened exclusively by user 'Admin' on machine ''. Try again when the database is available."

Kindly advise how to solve this problem.

View 2 Replies View Related

Access Form With VB Code

Oct 18, 2007

I have a form that is created in Access but uses some VB code. Here is my problem..... I have one form that the users do money transactions on. Then I have created a form that will allow them to Void a transaction as well as Refund a transaction. On the Void/Refund forms it will query the user for the Receipt No. once that information is pulled in, there is a command button that says "Void Ticket Sale" on the Refund form it says "Refund Ticket Sale". What I'm trying to do is, once the user enters the receipt no and hit that Void/Refund Ticket Sale button - if it has already been voided/refunded, a message box will come up and say "This Ticket has already been voided/refunded". If it has not, the "Void Ticket Sale" command will carry on. Here is a snippet of my code, I'm not sure what I'm doing wrong.

Private Sub cmdRefund_Click()
On Error GoTo Err_cmdRefund_Click
'this is a AddRec button, caption was changed to read Void

Dim Answer As Integer
Dim Result
Dim sqlstmt As String

sqlstmt = "Select Count( * ) from tbl_transactions where PaymentType = Void And VoidRefundID = Me.TransNumID"

Answer = sqlstmt

If Answer > 0 Then
MsgBox "This Receipt No. has already been voided."
Exit Sub
Else

Result = MsgBox("Are you sure you want to Refund Receipt No " + Str$(Me.TransNumID) + "?", vbYesNo, "Refund Receipt")

If Result = VbMsgBoxResult.vbNo Then
DoCmd.Close
Exit Sub
End If
End If

View 14 Replies View Related

Code For Parameter Form

Feb 24, 2012

I currently have a parameter form named "Fm_Commander_Parameter" and a report named "Rpt_Bldgs_by_Commander". On the parameter form I have a unbound drop down. On the After Update have I this code that opens the report.

Private Sub Cmb_Commander_AfterUpdate()
DoCmd.OpenReport "Rpt_Bldgs_by_Commander", acViewPreview
DoCmd.Close acForm, "Fm_Commander_Parameter"
End Sub

In the Query for the report for the Commander field I have the parameter as [Forms]![Fm_Commander_Parameter]![Cmb_Commander]..how to write code very well and am unsure this can be done, but what I would like to do is remove the 'After Update' on the form and on 'Open' of the report I would like to write a code to go to the form, allow them to select the commander, then go back to the report query with the selection. This way I could use the Parameter Form with other reports. Below is the code I've come up with that will be place in 'Open' on the report.

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Fm_Commander_Parameter", acNormal
(I don't know what to enter to keep the form open to enter the data. Without the below command it will run the report but the parameter form stays open.)
DoCmd.Close acForm, "Fm_Commander_Parameter"
End Sub

View 14 Replies View Related

Drawing On Form In Code

Nov 10, 2011

The access import wizard has a convenient form when a fixed-width file is to be imported. The form allows us to click the data to insert an arrow at a position where the next field should begin.

For my project, the wizard has some serious shortcomings, so I am trying to build my own import form. I can capture everything else needed to build an import routine, but I can't figure out, nor find examples of, allowing the user to place column breaks graphically.how to do this without using the wizard? Or rather, like in the wizard?

View 1 Replies View Related

Check Box VBA Code In A Form

Feb 17, 2015

I am trying to create form. I have a check box in my form with the name ChkDone.

I am going to write code for this check box and link it with some fields in my form.

The plan is if the check box is true or yes those fields will be available to insert data and if not they will be disabled.

View 3 Replies View Related

Search Product Code In Sub Form

Oct 8, 2007

:(I have a Customer Order form with a Order Detail sub form, The problem I have is that using the productID Combo, IT shows all 6000 products, I need a way to MANUALY enter the ProductID which then will find the relevant record and fill in the rest of the fields in the Sub Detail Order Form.

View 1 Replies View Related

Code To Dectect A Close Form

Oct 21, 2005

Hello,

What is the code to detect a close form? I have to put in a condition statment. Example :

If forms!frmWords.Close then

...

End if


But this don't work. The word "Close" isn't right. What is the snytaxe?

Thanks,

Le

View 4 Replies View Related

Form Browse Button Code

Dec 2, 2005

I am designing a form and I need to add a Browse button to it. I need the Browse Button to point to the "My Computer". Once that file is selected I need it to fill in the hyperlink box. I have the hyperlink text box on the form and it works if you manually type a link in. I would like it to auto fill-in with the selected file.

Any help would be great!!

Thank you :)

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved