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 Replies
ADVERTISEMENT
Feb 10, 2005
Hello all
I am having a problem with my vb code. I am realatively new to vb and what I am trying to do is search through a table according to what is selected on my form and delete the values that equal the value selected int the table. What I have so far is this
Private Sub cmdDel_Click()
Dim rsSource As DAO.Recordset
Dim rsDestination As DAO.Recordset
Dim theBug As String
Dim SelItm As Control
Set SelItm = Me.Users
If Me.Schedule.ItemsSelected.Count = 0 Then
Beep
Exit Sub
End If
Set rsDestination = _
CurrentDb.OpenRecordset("User_Course_Room", _
dbOpenDynaset)
For Each Itm In Me.Schedule.ItemsSelected
rsDestination.FindFirst "User_ID = " & Me.Users & "" And "Course_Room_ID = " & Me.Schedule.ItemData(Itm) & "" ### THIS LINE GIVES ME A ERROR
'rsDestination!Course_Room_ID = Me.Schedule.ItemData(Itm)
'rsDestination.FindFirst "Course_Room_ID = " & Me.Schedule.ItemData(Itm) & ""
rsDestination.Edit
rsDestination.Delete
Next Itm
Me.Sessions.Requery
Me.Schedule.Requery
End Sub
In the line with the bold writing next to it I get an error. What I am trying to do is search for the record with the user id selected and the course room id seleceted and delete that record but I get an error. Any help would be highly appreciated.
View 2 Replies
View Related
Apr 17, 2006
Hi All,
I have Header form and subform subform in it with following fields
Subform fields are :
1. MQE_No : (Text field as it will be like MG-120, MG230), Duplicate OK)
2. RPO_No : (Number field – Double, Duplicate OK ) The are project no.
3. ForemanNo (Number field – Long Int – Duplicate OK)
Header form fields are ;
1.ForemanNo – Long Int – No Duplicate
2.Other fields…
The subform field have ForemanNo One-To-many relationship with Header form.
Following project MG-411 need to enter (assign) to foreman no. 641
Actual data to store in subform
MG-411 (MQE_NO)
5421654 (RPO_NO)
641 (FOREMANNO)
I started to enter data into subform selecting the ForemanNo at header so records to enter in specific foremans account. Everything is fine here.
What I need is:
I would like to select / add another Foreman into the header and start entering same above data for another Foreman. Bcz sometimes we need to do like this in case previous Foreman may go on to a week vacation. We can not stop project for a week. So need to assign project to other foreman.
When selected the Project (MG-411) thru a combo to assign it with other foreman, it should give a short msg to user that this project has already been assigned to “XYZ” forman. Need to assign again “ (Y/N box )
If Y then data entered otherwise cancelled.
To achieve this, I did the following but only 50% success. (Used Cmbo CboRPO2 select MQE_NO). Tried to satisfy both condition but no use.
Private Sub CboRPO_AfterUpdate()
If DCount("*", "T_RPO_Footer", "RPO_No = " & RPO_No) > 0 And DCount("*", "T_RPO_Footer", "ENO = " & ENO) Then
MsgBox "RPO ALREADY ASSIGNED TO SOMEONE / FOREMAN", vbOKCancel, "WARNING!!!"
Me.Undo
Exit Sub
Else
Dim Msg, STYLE, TITLE, HELP, CTXT, Response, MYSTRING
If DCount("*", "T_RPO_Footer", "RPO_No = " & RPO_No) > 0 And DCount("*", "T_RPO_Footer", "ENO <> " & ENO) Then
Msg = "RPO ALREADY EXIST WITH OTHERFOREMAN, ASSIGN AGAIN TO ANOTHER ?"
STYLE = vbYesNo + vbInformation + vbDefaultButton2
TITLE = "!! ATTENTION !!"
HELP = "TEST FILE"
CTXT = 1000
Response = MsgBox(Msg, STYLE, TITLE, HELP, CTXT)
If Response = vbYes Then
Me.MQE_NO = Me.CboRPO.Column(0)
Me.RPO_No = Me.CboRPO.Column(1)
Me.WORKSHEET_NO = Me.CboRPO.Column(2)
Me.WORKORDER_NO = Me.CboRPO.Column(3)
Me.WORK_DESC = Me.CboRPO.Column(4)
Me.PL = Me.CboRPO.Column(5)
Me.PipeLineKM = Me.CboRPO.Column(6)
Me.DiaMeter = Me.CboRPO.Column(7)
Me.PipeLength = Me.CboRPO.Column(8)
Me.PipeLineArea = Me.CboRPO.Column(9)
Me.P = Me.CboRPO.Column(10)
Me.RPO_AMOUNT = Me.CboRPO.Column(12)
Me.INV_AMOUNT = Me.CboRPO.Column(13)
Me.Status = "WIP"
Me.StatusID = 2
Me.CboStatus.SetFocus
Else
Me.Undo
Exit Sub
End If
Else
Me.MQE_NO = Me.CboRPO.Column(0)
Me.RPO_No = Me.CboRPO.Column(1)
Me.WORKSHEET_NO = Me.CboRPO.Column(2)
Me.WORKORDER_NO = Me.CboRPO.Column(3)
Me.WORK_DESC = Me.CboRPO.Column(4)
Me.PL = Me.CboRPO.Column(5)
Me.PipeLineKM = Me.CboRPO.Column(6)
Me.DiaMeter = Me.CboRPO.Column(7)
Me.PipeLength = Me.CboRPO.Column(8)
Me.PipeLineArea = Me.CboRPO.Column(9)
Me.P = Me.CboRPO.Column(10)
Me.RPO_AMOUNT = Me.CboRPO.Column(12)
Me.INV_AMOUNT = Me.CboRPO.Column(13)
Me.Status = "WIP"
Me.StatusID = 2
Me.CboStatus.SetFocus
End If
End If
End Sub
I tried with following code also
'Dim cdn As String
'cdn = "[MQE_NO] = '" & Nz(CboRPO, "") & "'"
'cdn = cdn & " And ENO = " & ENO
'If DCount("*", "T_RPO_Footer", cdn) > 0 Then
'MsgBox "THIS RPO ALREADY ASSIGNED TO THIS FOREMAN", vbOKOnly, "WARNING!!!"
'Me.Undo
'Exit Sub
'Else
‘do something
‘End if
Can somebody help it please.
With kind regards,
Ashfaque
View 1 Replies
View Related
Sep 8, 2006
Hi everyone, i'm new from here!
i'm doing one of my school project, but i got a big problem with this.
from the photo, i've created a form like this. and i want to have a search system, searching data from table. so i've created 2 input box with 2 different searching methods.
both methods work the same. type in the Stuff ID and then click the search, datas will show like this.
but the problem is, i can't get the Search button working, whenever i press the search, it said that the Stuff ID can not be found. but i've that stuff id in my table!
Could anyone show me a solution of this. or is this method good? coz i'm not doing that with the VBA!
PS... sorry for chinese words. coz i'm from hong kong!
View 2 Replies
View Related
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
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
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
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 7 Replies
View Related
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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