10170 syntax error occurs for verilog codes to on/off the 7 segment LED - syntax-error

My project is about finding the common factor value between two inputs P[3:0] and Q[3:0]. The display output is G[13:0]. P,Q and G are 2 digits values. I am trying to build a display module for two digits 7 segment display with the code below. However, the compilation is fail.
this is my code:
module display(
input[3:0] p0,q0,
output reg[13:0]LEDp,LEDq,LEDg);
always #*
begin
case(p0)
4'b0000 : LEDp = 14'b11111111000000;
4'b0001 : LEDp = 14'b11111111111001;
4'b0010 : LEDp = 14'b11111110100100;
4'b0011 : LEDp = 14'b11111110110000;
4'b0100 : LEDp = 14'b11111110011001;
4'b0101 : LEDp = 14'b11111110010010;
4'b0110 : LEDp = 14'b11111110000010;
4'b0111 : LEDp = 14'b11111111111000;
4'b1000 : LEDp = 14'b11111110000000;
4'b1001 : LEDp = 14'b11111110010000;
4'b1010 : LEDp = 14'b11111101000000;
4'b1011 : LEDp = 14'b11111101111001;
4'b1100 : LEDp = 14'b11111100100100;
4'b1101 : LEDp = 14'b11111100110000;
4'b1110 : LEDp = 14'b11111100011001;
4'b1111 : LEDp = 14'b11111100010010;
default : LEDp = 14'b01111110111111;
endcase
end
always #*
begin
case (q0)
4'b0000: LEDq = 14'b11111111000000;
4'b0001: LEDq = 14'b11111111111001;
4'b0010: LEDq = 14'b11111110100100;
4'b0011: LEDq = 14'b11111110110000;
4'b0100: LEDq = 14'b11111110011001;
4'b0101: LEDq = 14'b11111110010010;
4'b0110: LEDq = 14'b11111110000010;
4'b0111: LEDq = 14'b11111111111000;
4'b1000: LEDq = 14'b11111110000000;
4'b1001: LEDq = 14'b11111110010000;
4'b1010: LEDq = 14'b11111101000000;
4'b1011: LEDq = 14'b11111101111001;
4'b1100: LEDq = 14'b11111100100100;
4'b1101: LEDq = 14'b11111100110000;
4'b1110: LEDq = 14'b11111100011001;
4'b1111: LEDq = 14'b11111100010010;
default: LEDq = 14'b01111110111111;
endcase
end
always #*
begin
case (G)
4'b0000: LEDg = 14'b11111111000000;
4'b0001: LEDg = 14'b11111111111001;
4'b0010: LEDg = 14'b11111110100100;
4'b0011: LEDg = 14'b11111110110000;
4'b0100: LEDg = 14'b11111110011001;
4'b0101: LEDg = 14'b11111110010010;
4'b0110: LEDg = 14'b11111110000010;
4'b0111: LEDg = 14'b11111111111000;
4'b1000: LEDg = 14'b11111110000000;
4'b1001: LEDg = 14'b11111110010000;
4'b1010: LEDg = 14'b11111101000000;
4'b1011: LEDg = 14'b11111101111001;
4'b1100: LEDg = 14'b11111100100100;
4'b1101: LEDg = 14'b11111100110000;
4'b1110: LEDg = 14'b11111100011001;
4'b1111: LEDg = 14'b11111100010010;
default: LEDg = 14'b01111110111111;
endcase
end
endmodule
The errors are:
Error (10170): Verilog HDL syntax error at display.v(8) near text ï
Error (10170): Verilog HDL syntax error at display.v(8) near text "ï"; expecting ":", or ","
Error (10170): Verilog HDL syntax error at display.v(8) near text ¼
Error (10170): Verilog HDL syntax error at display.v(8) near text š
May I know how should I correct it? I had searched through Internet but find no solutions.

When I copied your code and executed it in my software I noticed that you don't have colons (:) in your code only fullwidth colons (:). Changing this weird unicode colons to ascii colons almost solved all problems. You use also undefined G.

Related

How to optimize cloning in new roblox update

Everything has been going smooth until the new roblox update and now my barrage effect clones make the game insanely laggy.
Any help on optimizing it would be greatly appreciated.
I know this might sound lazy but it would be great if you could optimize it for me. I have 0 idea how to optimize and this is my last hope.
local EffectModule = require(game.ServerStorage:WaitForChild("HitEffectModule"))
local event = game:GetService("ReplicatedStorage"):WaitForChild("TheWorld").Barrage -- this is the event which fires from client to server
local TweenService = game:GetService("TweenService") -- this is a very useful function for extra effects
local Debris = game:GetService("Debris")
local Damage = 1.8
local Punched = game.Workspace.Sounds.Punched
--u can get ur own one im just using a free one as an example
local function Detect(Character)
local Hitbox = script.Hitbox:Clone()
Hitbox.Parent = workspace
Hitbox.CFrame = Character.PrimaryPart.CFrame * CFrame.new(0,0,Hitbox.Size.Z/2 * -1)
Debris:AddItem(Hitbox,.3)
local Connection
Connection = Hitbox.Touched:Connect(function(hitted)
if hitted.Parent:FindFirstChild("Humanoid") and not hitted:IsDescendantOf(Character) then
local Enemy = hitted.Parent
Enemy.Humanoid:TakeDamage(Damage)
Connection:Disconnect()
Hitbox:Destroy()
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e6,1e6,1e6)
bv.Velocity = Character.PrimaryPart.CFrame.LookVector * 10
Debris:AddItem(bv,.2)
bv.Parent = Enemy.PrimaryPart
EffectModule.Gore2(Enemy.UpperTorso)
Enemy.Humanoid:LoadAnimation(script.HitAnim):Play()
Punched:Play()
Enemy.Humanoid.WalkSpeed = 3
wait(1)
Enemy.Humanoid.WalkSpeed = 16
end
end)
end
local function CreateArm(Character)
local Stand = game:GetService("ServerStorage").StandModel.TheWorld
local StartXR = math.random(150,350)/100
Detect(Character)
local StartXL = math.random(150,350)/100 * -1
local StartYR = math.random(-150,250)/100
local StartYL = math.random(-150,250)/100
local LeftArmModel = Instance.new("Model")
LeftArmModel.Name = "LeftArm"
LeftArmModel.Parent = game.Workspace
Debris:AddItem(LeftArmModel,.3)
local LLA = Stand:FindFirstChild("LeftLowerArm"):Clone()
LLA.Parent = LeftArmModel
local LUA = Stand:FindFirstChild("LeftUpperArm"):Clone()
LUA.Parent = LeftArmModel
local LH = Stand:FindFirstChild("LeftHand"):Clone()
LH.Parent = LeftArmModel
local weld1 = Instance.new("WeldConstraint")
weld1.Part0 = LH
weld1.Part1 = LLA
weld1.Parent = LH
local weld2 = Instance.new("WeldConstraint")
weld2.Part0 = LUA
weld2.Part1 = LLA
weld2.Parent = LUA
for i , v in pairs(LeftArmModel:GetDescendants()) do
if v:IsA("Texture") or v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = .2
TweenService:Create(v,TweenInfo.new(.3),{Transparency = .75}):Play()
end
if v:IsA("Motor6D") then
v:Destroy()
end
end
LeftArmModel.PrimaryPart = LLA
LeftArmModel.PrimaryPart.Anchored = true
LeftArmModel.PrimaryPart.CFrame = CFrame.new(Character.PrimaryPart.CFrame * CFrame.new(StartXL,StartYL,-1.5).p,Character.PrimaryPart.CFrame * CFrame.new(StartXL * .4,StartYL * .4,-8).p) * CFrame.Angles(math.rad(90),0,0)
TweenService:Create(LeftArmModel.PrimaryPart,TweenInfo.new(.3),{CFrame = LeftArmModel.PrimaryPart.CFrame * CFrame.new(0,-5,0)}):Play()
local RightArmModel = Instance.new("Model")
RightArmModel.Name = "LeftArm"
RightArmModel.Parent = game.Workspace
Debris:AddItem(RightArmModel,.3)
local RLA = Stand:FindFirstChild("RightLowerArm"):Clone()
RLA.Parent = RightArmModel
local RUA = Stand:FindFirstChild("RightUpperArm"):Clone()
RUA.Parent = RightArmModel
local RH = Stand:FindFirstChild("RightHand"):Clone()
RH.Parent = RightArmModel
local weld1 = Instance.new("WeldConstraint")
weld1.Part0 = RH
weld1.Part1 = RLA
weld1.Parent = RH
local weld2 = Instance.new("WeldConstraint")
weld2.Part0 = RUA
weld2.Part1 = RLA
weld2.Parent = RUA
for i , v in pairs(RightArmModel:GetDescendants()) do
if v:IsA("Texture") or v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = .2
TweenService:Create(v,TweenInfo.new(.3),{Transparency = .75}):Play()
end
if v:IsA("Motor6D") then
v:Destroy()
end
end
RightArmModel.PrimaryPart = RLA
RightArmModel.PrimaryPart.Anchored = true
RightArmModel.PrimaryPart.CFrame = CFrame.new(Character.PrimaryPart.CFrame * CFrame.new(StartXR,StartYR,-1.5).p,Character.PrimaryPart.CFrame * CFrame.new(StartXR * .4,StartYR * .4,-8).p) * CFrame.Angles(math.rad(90),0,0)
TweenService:Create(RightArmModel.PrimaryPart,TweenInfo.new(.3),{CFrame = RightArmModel.PrimaryPart.CFrame * CFrame.new(0,-5,0)}):Play()
end
event.OnServerEvent:Connect(function(Player,hold)
local Character = Player.Character
local Stand = Character:FindFirstChild(Character.Name)
if Stand then
if not Character:FindFirstChild("Barraging") then
if hold == true and Character.UsingMove.Value == false then
local barraging = Instance.new("BoolValue")
barraging.Name = "Barraging"
barraging.Parent = Character
Character.UsingMove.Value = true
Character.PrimaryPart.StandPosition.Position = Vector3.new(0,-1,-2)
local Anim = Stand.AnimationController:LoadAnimation(script.Anim)
Anim:Play()
local Sound = script.BarrageSound:Clone()
Sound.Parent = Character.PrimaryPart
Sound:Play()
local Starttime = tick()
repeat
wait(.30)
CreateArm(Character)
until tick() - Starttime >= 5 or not Character:FindFirstChild("Barraging")
Character.PrimaryPart.StandPosition.Position = Vector3.new(-2,0.7,3)
Anim:Stop()
Sound:Destroy()
Character.UsingMove.Value = false
end
else
Character:FindFirstChild("Barraging"):Destroy()
end
end
end)
Instead of cloning it from a storage, at the start just clone a bunch of them and keep them very high up in sky so that it wont be rendered, and as you need them position them accordingly while switching them.

NuSMV :: Wrong counterexamples for Finally property

I want to model a symmetric distributed four processor three coloring protocol with nuSMV. My specification - which I am sure about its correctness - must be true but when I use keyword "F" for "Finally" property, nuSMV gives me a counterexample at very first step and stops processing next states.
What should I do to make it fixed and check Finally property in LTL?
Here is my SMV code:
MODULE proc(former_proc ,further_proc )
VAR
self_proc : {zero, on, two};
ASSIGN
init(self_proc) :={zero, on, two};
next(self_proc) :=
case
(self_proc = two) & (further_proc = two | further_proc = zero) & (former_proc = two) : on;
(self_proc = two) & (further_proc = two) & (former_proc = zero) : zero;
(self_proc = on) & (further_proc = two | further_proc = on) & (former_proc = on) : zero;
(self_proc = on | self_proc = zero) & (further_proc = on) & (former_proc = zero) : two;
(self_proc = on) & (further_proc = zero) & (former_proc = on) : two;
(self_proc = zero) & (further_proc = zero) & (former_proc = on | former_proc = zero) : two;
TRUE : self_proc;
esac;
MODULE main
VAR
p1 : process proc( p4.self_proc ,p2.self_proc );
p2 : process proc( p1.self_proc ,p3.self_proc );
p3 : process proc( p2.self_proc ,p4.self_proc );
p4 : process proc( p3.self_proc ,p1.self_proc );
FAIRNESS running
LTLSPEC F((p1.self_proc != p2.self_proc) & (p1.self_proc != p4.self_proc) & (p2.self_proc != p3.self_proc) & (p3.self_proc != p4.self_proc))
and here is my counterexample from nuSMV:
-- specification F (((p1.self_proc != p2.self_proc & p1.self_proc != p4.self_proc) & p2.self_proc != p3.self_proc) & p3.self_proc != p4.self_proc) is false
-- as demonstrated by the following execution sequence
Trace Description: LTL Counterexample
Trace Type: Counterexample
-- Loop starts here
-> State: 1.1 <-
p1.self_proc = on
p2.self_proc = on
p3.self_proc = zero
p4.self_proc = zero
-> Input: 1.2 <-
_process_selector_ = main
running = TRUE
p4.running = FALSE
p3.running = FALSE
p2.running = FALSE
p1.running = FALSE
-- Loop starts here
-> State: 1.2 <-
-> Input: 1.3 <-
-> State: 1.3 <-
Thank you.

How to add button on a cell and if some field is null not to add button in developer express grid

I have a grid with buttons on two columns but if a field is null I don't want that button to be visible. I am working in Delphi; I found solution in VB
Private Sub gridView1_CustomRowCellEdit(ByVal sender As Object, ByVal e As CustomRowCellEditEventArgs) Handles gridView1.CustomRowCellEdit
If e.Column Is gridColumn1 Then
Dim ri As RepositoryItemButtonEdit = TryCast(e.RepositoryItem.Clone(), RepositoryItemButtonEdit)
ri.Assign(e.RepositoryItem)
e.RepositoryItem = ri
Dim buttonCount As Integer = CInt(Fix(gridView1.GetRowCellValue(e.RowHandle,gridColumn2)))
For i As Integer = 0 To buttonCount - 1
TryCast(e.RepositoryItem, RepositoryItemButtonEdit).Buttons(i).Visible = True
Next i
End If
End Sub
But this event does not exist in Delphi. Which event should I use? And how to solve this problem if tblMailJournalTask.FieldByName('anQId').Value = nullnot to show button.
I've set up a grid in which the Properties value of the 3rd column (called cxGrid1DBTableView1Value) is set to ButtonEdit.
Then, the code below causes the button not to be displayed in the cell if the data value in the cell is Null.
Obviously, if there is more than one button in the cell, you could iterate over them to set the Visible property of each of them, if you want all of them to be hidden when the data value is Null.
procedure TForm1.cxGrid1DBTableView1ValueGetPropertiesForEdit(Sender:
TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AProperties:
TcxCustomEditProperties);
var
ADataRow : TcxGridDataRow;
AValue : Variant;
begin
if ARecord is TcxGridDataRow then begin
ADataRow := TcxGridDataRow(ARecord);
Assert(ADataRow.ValueCount > 0); // this is for debugging/testing
AValue := ADataRow.Values[2]; // the value in the third column
if Assigned(AProperties.Buttons) then begin // this test is for debugging/testing
if VarIsNull(AValue) then
AProperties.Buttons[0].Visible := False
else
AProperties.Buttons[0].Visible := True;
end;
end;
end;
Update: If you want to show yourself that clicking the button does something, do the following:
Select your grid column in the Object Inspector
Click on the Events tab
Scroll down to the Properties entry, and click it to expand it
Double-click in its OnButtonClick and add something like the following.
.
procedure TForm1.cxGrid1DBTableView1ValuePropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
ShowMessage(IntToStr(AButtonIndex));
end;
Update2
Here is the complete code & DFM of a project which behaves as I've described above.
Code:
unit CXSimpleLocalu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Variants, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
cxStyles, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter,
cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, cxNavigator, DB,
cxDBData, cxButtonEdit, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
DBClient, StdCtrls;
type
TForm1 = class(TForm)
CDS1: TClientDataSet;
DataSource1: TDataSource;
CDS1ID: TAutoIncField;
CDS1Name: TStringField;
CDS1Value: TStringField;
CDS1Selected: TBooleanField;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1ID: TcxGridDBColumn;
cxGrid1DBTableView1Name: TcxGridDBColumn;
cxGrid1DBTableView1Value: TcxGridDBColumn;
cxGrid1DBTableView1Selected: TcxGridDBColumn;
procedure cxGrid1DBTableView1ValueGetPropertiesForEdit(Sender:
TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AProperties:
TcxCustomEditProperties);
procedure FormCreate(Sender: TObject);
procedure cxGrid1DBTableView1ValuePropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
private
{ Private declarations }
protected
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.cxGrid1DBTableView1ValueGetPropertiesForEdit(Sender:
TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AProperties:
TcxCustomEditProperties);
var
ADataRow : TcxGridDataRow;
AValue : Variant;
begin
if ARecord is TcxGridDataRow then begin
ADataRow := TcxGridDataRow(ARecord);
Assert(ADataRow.ValueCount > 0);
AValue := ADataRow.Values[2];
if Assigned(AProperties.Buttons) then begin
if VarIsNull(AValue) then
AProperties.Buttons[0].Visible := False
else
AProperties.Buttons[0].Visible := True;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
begin
CDS1.CreateDataSet;
for i:= 0 to 5 do begin
CDS1.Insert;
CDS1.FieldByName('Name').AsString := Chr(i + Ord('a'));
if Odd(i) then
CDS1.FieldByName('Value').AsString := '#';
CDS1.Post;
end;
// CDS1.MergeChangeLog;
end;
procedure TForm1.cxGrid1DBTableView1ValuePropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
ShowMessage(IntToStr(AButtonIndex));
end;
end.
DFM:
object Form1: TForm1
Left = 348
Top = 166
AutoScroll = False
Caption = 'MADefaultForm'
ClientHeight = 314
ClientWidth = 444
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object cxGrid1: TcxGrid
Left = 0
Top = 0
Width = 444
Height = 314
Align = alClient
TabOrder = 1
object cxGrid1DBTableView1: TcxGridDBTableView
Navigator.Buttons.CustomButtons = <>
DataController.DataSource = DataSource1
DataController.KeyFieldNames = 'ID'
DataController.Summary.DefaultGroupSummaryItems = <>
DataController.Summary.FooterSummaryItems = <>
DataController.Summary.SummaryGroups = <>
object cxGrid1DBTableView1ID: TcxGridDBColumn
DataBinding.FieldName = 'ID'
end
object cxGrid1DBTableView1Name: TcxGridDBColumn
DataBinding.FieldName = 'Name'
end
object cxGrid1DBTableView1Value: TcxGridDBColumn
DataBinding.FieldName = 'Value'
PropertiesClassName = 'TcxButtonEditProperties'
Properties.Buttons = <
item
Default = True
Kind = bkEllipsis
end>
Properties.OnButtonClick = cxGrid1DBTableView1ValuePropertiesButtonClick
OnGetPropertiesForEdit = cxGrid1DBTableView1ValueGetPropertiesForEdit
end
object cxGrid1DBTableView1Selected: TcxGridDBColumn
DataBinding.FieldName = 'Selected'
PropertiesClassName = 'TcxButtonEditProperties'
Properties.Buttons = <
item
Default = True
Kind = bkEllipsis
end>
end
end
object cxGrid1Level1: TcxGridLevel
GridView = cxGrid1DBTableView1
end
end
object CDS1: TClientDataSet
Aggregates = <>
Params = <>
Left = 24
Top = 16
object CDS1ID: TAutoIncField
FieldName = 'ID'
end
object CDS1Name: TStringField
FieldName = 'Name'
Size = 8
end
object CDS1Value: TStringField
FieldName = 'Value'
Size = 32
end
object CDS1Selected: TBooleanField
FieldName = 'Selected'
end
end
object DataSource1: TDataSource
DataSet = CDS1
Left = 64
Top = 16
end
end

textbox lines into listview subitems vb.net

i have an app that detect wifi networks
i have a listviewitems with wifi ssid , signal and security and i have
a richtextbox that each line contains mac address of each ssid that is ordred
i want to add each line to each item as subitem
i used this code but number of items are changeable
LVW.Items(0).SubItems(3).Text = RichTextBox1.Lines(0)
LVW.Items(1).SubItems(3).Text = RichTextBox1.Lines(1)
LVW.Items(2).SubItems(3).Text = RichTextBox1.Lines(2)
LVW.Items(4).SubItems(3).Text = RichTextBox1.Lines(4)
LVW.Items(5).SubItems(3).Text = RichTextBox1.Lines(5)
LVW.Items(6).SubItems(3).Text = RichTextBox1.Lines(6)
LVW.Items(7).SubItems(3).Text = RichTextBox1.Lines(7)
LVW.Items(8).SubItems(3).Text = RichTextBox1.Lines(8)
LVW.Items(9).SubItems(3).Text = RichTextBox1.Lines(9)
LVW.Items(10).SubItems(3).Text = RichTextBox1.Lines(10)
LVW.Items(11).SubItems(3).Text = RichTextBox1.Lines(11)
LVW.Items(12).SubItems(3).Text = RichTextBox1.Lines(12)
LVW.Items(13).SubItems(3).Text = RichTextBox1.Lines(13)
LVW.Items(14).SubItems(3).Text = RichTextBox1.Lines(14)
LVW.Items(15).SubItems(3).Text = RichTextBox1.Lines(15)
here's the picture
Try this:
If RichTextBox1.Lines.Count > 0 And LVW.Items.Count = RichTextBox1.Lines.Count Then
For i As Integer = 0 To RichTextBox1.Lines.Count - 1
LVW.Items(i).SubItems(3).Text = RichTextBox1.Lines(i)
Next
Else
MsgBox("Invalid number of lines in RichTextBox1")
End If

Run-time error 91: Object variable or With block variable not set

I'm using Access 2010 VBA that is returning a recordset from an IBM iSeries. I have the following loop to append the recordset to a local table:
'Loop through recordset and place values
Do While rsti401.EOF = False
Set rst401 = CurrentDb.OpenRecordset("tblLocal_SL401WK", dbOpenDynaset, dbSeeChanges)
With rst401
.AddNew
.Fields("PC") = rsti401.Fields("PC")
.Fields("TIME") = rsti401.Fields("TIME")
.Fields("CONO") = rsti401.Fields("CONO")
.Fields("STYCOL") = rsti401.Fields("STYCOL")
.Fields("WHSE") = rsti401.Fields("WHSE")
.Fields("CUNO") = rsti401.Fields("CUNO")
.Fields("SIZE01") = rsti401.Fields("SIZE01")
.Fields("SIZE02") = rsti401.Fields("SIZE02")
.Fields("SIZE03") = rsti401.Fields("SIZE03")
.Fields("SIZE04") = rsti401.Fields("SIZE04")
.Fields("SIZE05") = rsti401.Fields("SIZE05")
.Fields("SIZE06") = rsti401.Fields("SIZE06")
.Fields("SIZE07") = rsti401.Fields("SIZE07")
.Fields("SIZE08") = rsti401.Fields("SIZE08")
.Fields("SIZE09") = rsti401.Fields("SIZE09")
.Fields("SIZE10") = rsti401.Fields("SIZE10")
.Fields("SIZE11") = rsti401.Fields("SIZE11")
.Fields("SIZE12") = rsti401.Fields("SIZE12")
.Fields("SIZE13") = rsti401.Fields("SIZE13")
.Fields("SIZE14") = rsti401.Fields("SIZE14")
.Fields("SIZE15") = rsti401.Fields("SIZE15")
.Fields("BQTY01") = rsti401.Fields("BQTY01")
.Fields("BQTY02") = rsti401.Fields("BQTY02")
.Fields("BQTY03") = rsti401.Fields("BQTY03")
.Fields("BQTY04") = rsti401.Fields("BQTY04")
.Fields("BQTY05") = rsti401.Fields("BQTY05")
.Fields("BQTY06") = rsti401.Fields("BQTY06")
.Fields("BQTY07") = rsti401.Fields("BQTY07")
.Fields("BQTY08") = rsti401.Fields("BQTY08")
.Fields("BQTY09") = rsti401.Fields("BQTY09")
.Fields("BQTY10") = rsti401.Fields("BQTY10")
.Fields("BQTY11") = rsti401.Fields("BQTY11")
.Fields("BQTY12") = rsti401.Fields("BQTY12")
.Fields("BQTY13") = rsti401.Fields("BQTY13")
.Fields("BQTY14") = rsti401.Fields("BQTY14")
.Fields("BQTY15") = rsti401.Fields("BQTY15")
.Update
End With
rsti401.MoveNext
Loop
'close connections
rsti401.Close
rst401.Close
IBM.Close
Set IBM = Nothing
Set rst401 = Nothing
Set rsti401 = Nothing
Set CMD = Nothing
However, each time I run it I is stopping at the following line:
rst401.Close
With error 'Run-time error 91'. I can't work it out. I've set rst401 at the beginning, so why am I still getting the error.
Any pointers would be a great help.
Thanks,
Michael
The problem you have is because the rst401 is set inside the Do While Loop, and you are trying to close an object that has lost its scope outside the Loop. Suggest you make the following changes.
'Loop through recordset and place values
Set rst401 = CurrentDb.OpenRecordset("tblLocal_SL401WK", dbOpenDynaset, dbSeeChanges)
Do While rsti401.EOF = False
With rst401
.AddNew
.Fields("PC") = rsti401.Fields("PC")
.Fields("TIME") = rsti401.Fields("TIME")
.Fields("CONO") = rsti401.Fields("CONO")
.Fields("STYCOL") = rsti401.Fields("STYCOL")
.Fields("WHSE") = rsti401.Fields("WHSE")
.Fields("CUNO") = rsti401.Fields("CUNO")
.Fields("SIZE01") = rsti401.Fields("SIZE01")
.Fields("SIZE02") = rsti401.Fields("SIZE02")
.Fields("SIZE03") = rsti401.Fields("SIZE03")
.Fields("SIZE04") = rsti401.Fields("SIZE04")
.Fields("SIZE05") = rsti401.Fields("SIZE05")
.Fields("SIZE06") = rsti401.Fields("SIZE06")
.Fields("SIZE07") = rsti401.Fields("SIZE07")
.Fields("SIZE08") = rsti401.Fields("SIZE08")
.Fields("SIZE09") = rsti401.Fields("SIZE09")
.Fields("SIZE10") = rsti401.Fields("SIZE10")
.Fields("SIZE11") = rsti401.Fields("SIZE11")
.Fields("SIZE12") = rsti401.Fields("SIZE12")
.Fields("SIZE13") = rsti401.Fields("SIZE13")
.Fields("SIZE14") = rsti401.Fields("SIZE14")
.Fields("SIZE15") = rsti401.Fields("SIZE15")
.Fields("BQTY01") = rsti401.Fields("BQTY01")
.Fields("BQTY02") = rsti401.Fields("BQTY02")
.Fields("BQTY03") = rsti401.Fields("BQTY03")
.Fields("BQTY04") = rsti401.Fields("BQTY04")
.Fields("BQTY05") = rsti401.Fields("BQTY05")
.Fields("BQTY06") = rsti401.Fields("BQTY06")
.Fields("BQTY07") = rsti401.Fields("BQTY07")
.Fields("BQTY08") = rsti401.Fields("BQTY08")
.Fields("BQTY09") = rsti401.Fields("BQTY09")
.Fields("BQTY10") = rsti401.Fields("BQTY10")
.Fields("BQTY11") = rsti401.Fields("BQTY11")
.Fields("BQTY12") = rsti401.Fields("BQTY12")
.Fields("BQTY13") = rsti401.Fields("BQTY13")
.Fields("BQTY14") = rsti401.Fields("BQTY14")
.Fields("BQTY15") = rsti401.Fields("BQTY15")
.Update
End With
rsti401.MoveNext
Loop
'close connections
rsti401.Close
rst401.Close
IBM.Close
Set IBM = Nothing
Set rst401 = Nothing
Set rsti401 = Nothing
Set CMD = Nothing